Android does not actually have the concept of a dialog box, and some just use PopupWindow to implement the effect of a dialog box. The following is a complete example and usage.
Create a PromptWindow class
Package com. friendlocation; import java. util. arrayList; import android. app. activity; import android. content. context; import android. graphics. drawable. drawable; import android. view. view; import android. view. viewGroup; import android. view. view. onClickListener; import android. widget. adapterView; import android. widget. button; import android. widget. listView; import android. widget. popupWindow; import android. widget. TextView; import android. widget. adapterView. onItemClickListener; public class PromptWindow extends PopupWindow {// list item Activity context; View popupView; OnBtnClickedListener listener; public PromptWindow (Activity context, int width, int height) {super (context ); this. context = context; // create popupView = context. getLayoutInflater (). inflate (R. layout. prompt_window, null); Button btnOk = (Button) popupView. findVie WById (R. id. btn_ OK); btnOk. setOnClickListener (new OnClickListener () {public void onClick (View view) {if (listener! = Null) listener. onBtnOkClicked (PromptWindow. this) ;}}); // display the dialog box this. setContentView (popupView); this. setWidth (width); this. setHeight (height); setFocusable (true); setBackgroundDrawable (context. getResources (). getDrawable (R. drawable. shape_menu); // setBackgroundDrawable (new BitmapDrawable ();} public interface OnBtnClickedListener {public void onBtnOkClicked (PopupWindow win);} public void listener (OnBtnClickedListener l) {listener = l ;}}
Create a layout file prompt_export layout XML under res/layout.
Have you understood all of them?
Show dialog box
PromptWindow win = new PromptWindow (this, 420,240); win. showAtLocation (this. findViewById (R. id. titlebar), Gravity. CENTER, 0, 0); // what to do when you click the button win. setOnBtnClickedListener (new PromptWindow. onBtnClickedListener () {public void onBtnOkClicked (PopupWindow w) {w. dismiss (); // Intent intent = new Intent (MainActivity. this, RegisterActivity. class); startActivityForResult (intent, 100 );}});
Certificate ----------------------------------------------------------------------------------------------------------------------------------
"Star family and friends positioning": simple and practical, is a Positioning Software for family and friends, real-time query of the location of the other side and display in a map. It is very suitable for use at home and abroad, with one less worry, one more security guarantee, and the ability to know the whereabouts of family members in a timely manner, so as to avoid the inability to find children and the elderly.
(Its real-time and automatic features ensure that family members do not lose the chain when they are in danger)
The other party does not need to use a smartphone because the software can set a whitelist for automatic reply, and the other party can obtain the location of the other party without any operation.
You do not need to open the software reply or start the software in advance.
Download location:360 market (you can use the 360 mobile phone assistant to download the keyword "Polar Star" and "positioning of polar stars and friends ")
-If both parties install the software and enable the GPS function (generally, all mobile phones are enabled), enter the recipient's mobile phone number and query the location.
-You can select a contact from the address book or from the "recent contact" menu.
-The whitelist is used to specify trusted contacts and automatically replies to their query requests.
-The map display function is integrated. If Baidu map software has been installed on your mobile phone, you can display the location of the other party on the map.
-Misoperation prevention: the sending button uses a delayed response design. It is confirmed to be sent only after you press it for about 1 second, and the message is sent with a prompt of vibration and text.