Hi.
The code below will popup a dialog box, giving the option to continue or end the program.
I want to customize the box using a text view.
The uncommented setting does however not work.
How can I link this?
import processing.core.PApplet;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.graphics.Color;
import android.widget.TextView;
import android.view.Gravity;
Activity act;
TextView msg;
void setup() {
background(0);
textSize(38);
textAlign(CENTER);
text("Click on screen", width/2, height/2);
}
void draw(){
}
void dialogBox() {
act = this.getActivity();
TextView msg = new TextView(act);
msg.setText("I am a Custom Dialog Box.");
msg.setGravity(Gravity.CENTER_HORIZONTAL);
msg.setTextColor(Color.BLACK);
act.runOnUiThread(new Runnable() {
public void run() {
new AlertDialog.Builder(act)
//.setView(msg)
.setTitle("Do you want to quit?")
.setPositiveButton("NO",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
}
}
)
.setNegativeButton("YES",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
act.finish();
}
}
)
.show();
}
}
);
}
void mousePressed(){
dialogBox();
}