The post below will display how to create an AlertDialog in an Android app.
Within the onCreate method, under setContentView, add the following code:
AlertDialog alert = new AlertDialog.Builder(YourActivity.this).create();
alert.setTitle("Hello world");
alert.setMessage("My message");
alert.setButton("Button name",new DialogInterface.setOnClickListener() {
add what you want your button to do in this block
};
alert.show();
Although, AlertDialog is now deprecated, it will still work in Ice Cream Sandwich and above.
Happy coding!
Check my latest car app by clicking here
No comments:
Post a Comment