Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Pop-up message

Tags:

android

popup

I'm trying to get a pop up text box, with some disclaimer and app info at the start of my Android application's launch. Does anyone know how to implement this? Also could it read from a txt file?

Thanks

like image 615
Ranger Avatar asked Mar 30 '11 11:03

Ranger


People also ask

How do I set up pop-up messages on my Android?

There are two steps to displaying a message. First, you create a Snackbar object with the message text. Then, you call that object's show() method to display the message to the user.

What is Android pop-up notification?

The terms pop-up notification, toast, passive pop-up, snackbar, desktop notification, notification bubble, or simply notification all refer to a graphical control element that communicates certain events to the user without forcing them to react to this notification immediately, unlike conventional pop-up windows.

What is the pop-up message?

A popup notification is a message that appears on your users' browser or desktop. They're designed to grab your audience's attention and engage them in some way.


2 Answers

If you want a Popup that closes automatically, you should look for Toasts. But if you want a dialog that the user has to close first before proceeding, you should look for a Dialog.

For both approaches it is possible to read a text file with the text you want to display. But you could also hardcode the text or use R.String to set the text.

like image 162
RoflcoptrException Avatar answered Oct 21 '22 00:10

RoflcoptrException


You can use Dialog to create this easily

create a Dialog instance using the context

Dialog dialog = new Dialog(contex); 

You can design your layout as you like.

You can add this layout to your dialog by dialog.setContentView(R.layout.popupview);//popup view is the layout you created

then you can access its content (textviews, etc.) by using findViewById method

TextView txt = (TextView)dialog.findViewById(R.id.textbox); 

you can add any text here. the text can be stored in the String.xml file in res\values.

txt.setText(getString(R.string.message)); 

then finally show the pop up menu

dialog.show(); 

more information http://developer.android.com/guide/topics/ui/dialogs.html

http://developer.android.com/reference/android/app/Dialog.html

like image 31
Chamila Adhikarinayake Avatar answered Oct 21 '22 02:10

Chamila Adhikarinayake