开发者

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.


  1. Customize the dialog using this tutorial.
  2. Then remove that button in XML
  3. Then add a handler -- this link -- and close the dialog after a certain duration.

or

  1. Use a toast message.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜