开发者

Pop-Up display in Android using alertdialog.builder

I am new to Android Programming. I need to display a Pop-Up message in my application which I h开发者_如何学Pythonave no clue about. I got to hear from somewhere that it can be done using alertdialog.builder, but I have no idea how to do that?

I just want to display a simple Text Message.

Can anybody please help me out regarding this with an example if possible.


If you want to display a simple message you're probably better off using a Toast.

Toast.makeText(this, "Some Text", Toast.LENGTH_LONG).show();

Or, if you're doing it properly, and using a String resource:

Toast.makeText(this, getString(R.string.message_toast), Toast.LENGTH_LONG).show();


If you really need a pop up that the user has to acknowledge by pressing a button, you can do something like this:

new AlertDialog.Builder(context).setMessage("message text").setPositiveButton("OK", null).setTitle("Title").show();

you can leave out setTitle if you don't need it

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜