How to display an Alert box without cancel and ok button?
I like to create 开发者_运维技巧an Alert box without ok and cancel button. The alert box should display for a particular period of time.
Try this code
"AlertDialog.Builder alertbox = new AlertDialog.Builder(MainActivity.this);
alertbox.setMessage("Do You want to Save?");
alertbox.create();
alertbox.show();"
it will help you...
You can use a Toast:
Toast toast = Toast.makeText(this, getString(R.string.my_string, Toast.LENGTH_SHORT);
toast.show();
http://www.androidpeople.com/android-custom-dialog-example
remove the button in the example.
You can use the class AlarmManager or TimerTask to display the number for a limited time. To remove the "Ok" and "Cancel" buttons, you can use the LayoutInflater.
- Customize the dialog using this tutorial.
- Then remove that button in XML
- Then add a handler -- this link -- and close the dialog after a certain duration.
or
- Use a toast message.
精彩评论