Open MyActivity.java. Let's modify the onCreate method:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AlertDialog dialog = new AlertDialog.Builder(this).create();
dialog.setTitle("It's an alert!");
dialog.setMessage("This alert has a message.");
dialog.setIcon(R.drawable.icon);
dialog.setButton("OK", new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialogInterface, int i) {
return;
}
});
dialog.show();
}
Redeploy (mvn clean install) and you'll see the alert when you launch your app.
There is also a dialog.setButton2 and dialog.setButton3. Surprisingly, Button3 seems to be in the middle.
ReplyDelete