-
Notifications
You must be signed in to change notification settings - Fork 0
/
Radio buttons (single choice)
62 lines (56 loc) · 1.57 KB
/
Radio buttons (single choice)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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();
}