# Radio buttons Processing for Android (single choice)

**URL:** <https://discourse.processing.org/t/radio-buttons-processing-for-android-single-choice/15829>\
**Category:** Processing for Android\
**Created:** [November 26, 2019, 12:04pm UTC](https://discourse.processing.org/t/radio-buttons-processing-for-android-single-choice/15829 "2019-11-26T12:04:36Z")\
**Posts on this page:** 3\
**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, 12:04pm UTC](https://discourse.processing.org/t/radio-buttons-processing-for-android-single-choice/15829/1 "2019-11-26T12:04:36Z")

</div>

Following short code, can be useful in your Android’s Processing sketch.  
Please comment if any error.

```auto
import android.content.DialogInterface;
import android.app.Activity;
import android.app.AlertDialog;

CharSequence[] values = {" First Item ", " Second Item ", " Third Item "}; 
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);
      builder.setTitle("Select Your Choice");
      builder.setSingleChoiceItems(values, -1, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int item) {
          switch(item)
          {
          case 0:
            background(#F9C454);
            text("Click on screen", width/2, height/3);
            text("First Item Clicked", width/2, height/2);
            break;
          case 1:
            background(#F9C454);
            text("Click on screen", width/2, height/3);
            text("Second Item Clicked", width/2, height/2);   
            break;
          case 2:
            background(#F9C454);
            text("Click on screen", width/2, height/3);
            text("Third Item Clicked", width/2, height/2);   
            break;
          }
        }
      }
      );
      builder.setPositiveButton("CONFIRM", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
        }
      }
      )
      .show();
    }
  }
  );
}

void mousePressed() {
  dialogBox();
}

```

 ![Screenshot_2019-11-26-09-05-21](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/8/82bfeb54b83c19f8fb7d417c80853121f2854fa1.png)

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [November 26, 2019, 12:36pm UTC](https://discourse.processing.org/t/radio-buttons-processing-for-android-single-choice/15829/2 "2019-11-26T12:36:54Z")

</div>

@noel

thank you !!!thank you !!!

---

<div class="post-metadata">

**Author:** ![RAW](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/raw/32/7303_2.png) [@RAW](https://discourse.processing.org/u/RAW)\
**Post date:** [November 29, 2019, 11:51am UTC](https://discourse.processing.org/t/radio-buttons-processing-for-android-single-choice/15829/3 "2019-11-29T11:51:23Z")

</div>

// great …!!! great …!!!
