# Edit text box Processing for Android

**URL:** https://discourse.processing.org/t/edit-text-box-processing-for-android/15833
**Category:** Processing for Android
**Created:** [November 26, 2019, 1:04pm UTC](https://discourse.processing.org/t/edit-text-box-processing-for-android/15833 "2019-11-26T13:04:26Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)
#### Post date: [November 26, 2019, 1:04pm UTC](https://discourse.processing.org/t/edit-text-box-processing-for-android/15833/1 "2019-11-26T13:04:26Z")

</div>

Another utility for your Android’s Processing sketch based on Alert Dialog. It can be handy to write a file name to be saved or changing a variable.  
Please comment if any error.

```auto
import android.content.DialogInterface;
import android.app.Activity;
import android.app.AlertDialog;
import android.text.Editable;
import android.widget.EditText;

Activity act;

void setup() {
  background(#F9C454);
  fill(#4A3A16);
  textSize(38);
  textAlign(CENTER);
  text("Click on screen", width/2, height/3);
}

void draw() {
}  

void dialogBox() {
  act = this.getActivity();
  act.runOnUiThread(new Runnable() {
    public void run() {
      AlertDialog.Builder builder = new AlertDialog.Builder(act);
      final EditText input = new EditText(act); 
      builder.setView(input); 
      builder.setTitle("strokeWeight:");
      builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { 
        public void onClick(DialogInterface dialog, int whichButton) { 
          background(#F9C454);
          text("Click on screen", width/2, height/3);
          String value = input.getText().toString().trim(); 
          text(value, width/2, height/2);
        }
      }
      );
      builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { 
        public void onClick(DialogInterface dialog, int whichButton) { 
          dialog.cancel();
        }
      }
      ); 
      builder.show();
    }
  }
  );
}

void mousePressed() {
  dialogBox();
}

```

 ![Screenshot_2019-11-26-10-04-45](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/1/178103831a9871943cdcbfde3f62fc6a8248f0ef.png)

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [November 26, 2019, 1:20pm UTC](https://discourse.processing.org/t/edit-text-box-processing-for-android/15833/2 "2019-11-26T13:20:11Z")

</div>

as this is very good work i wanted to say  
it should be in the “examples”  
[https://android.processing.org/](https://android.processing.org/)  
OOPS not have that ???  
but you could pack it:  
tutorial  
[https://android.processing.org/tutorials/index.html](https://android.processing.org/tutorials/index.html)  
WIKI  
[https://github.com/processing/processing-android/wiki](https://github.com/processing/processing-android/wiki) .

---

<div class="post-metadata">

### Author: ![dimpapadop](https://avatars.discourse-cdn.com/v4/letter/d/ba9def/32.png) [@dimpapadop](https://discourse.processing.org/u/dimpapadop)
#### Post date: [January 31, 2021, 4:06pm UTC](https://discourse.processing.org/t/edit-text-box-processing-for-android/15833/3 "2021-01-31T16:06:04Z")

</div>

and if you want to set default value to the input text you can set

```auto
      AlertDialog.Builder builder = new AlertDialog.Builder(actDialog);
      final EditText input = new EditText(actDialog); 
      builder.setView(input); 
      builder.setTitle("Pocket Smartboard main ip :");
// try to set default value
      if (!HostIP.equals("")) input.setText(HostIP);  

```

---

<div class="post-metadata">

### Author: ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)
#### Post date: [January 31, 2021, 7:02pm UTC](https://discourse.processing.org/t/edit-text-box-processing-for-android/15833/4 "2021-01-31T19:02:20Z")

</div>

In addition, adding these lines of code will permit the user to enter only numbers:

```auto
import android.text.InputType;
...
 builder.setTitle("Enter a number:");
 input.setInputType(InputType.TYPE_CLASS_NUMBER);

```
