1. Alertdialog dialog box
Alertdialog.builder builder=new Builder (homeactivity.this); Builder.settitle ("hint"); Builder.setmessage ("Do you want to delete information?"); Builder.setpositivebutton ("Yes", new Onclicklistener () {@Overridepublic void OnClick (dialoginterface dialog, int which) { New asynctask<void, Void, void> () {@Overrideprotected void Doinbackground (void ... params) {//agree to write the current data to the Leave request form if ( Mrejectleaveinfodao==null) {mrejectleaveinfodao=new Rejectleaveinfosdao (homeactivity.this);} Else{mrejectleaveinfodao.deleteleaveinfo (tmpinforeject);} Filldatareject (); return null;}}. Execute ();}}); Builder.setnegativebutton ("No", new Onclicklistener () {@Overridepublic void OnClick (dialoginterface dialog, int which) { Dialog.dismiss ();}}); Builder.create (). Show ();
2. Dialog dialog box
New Asynctask<void,object, void> () {list<virusapp> apps=new arraylist<virusapp> (); String desc=null;dialog dialog=new Dialog (killvirusactivity.this); View viewkilling=view.inflate (killvirusactivity.this,r.layout.killing_dialog,null); @Overrideprotected void OnPreExecute () {Mkillvirusresult.settext ("scanning, please wait ...");d ialog.setcancelable (False);d Ialog.setcontentview ( viewkilling);d ialog.show ();
corresponding layout file:
<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android " android:layout_width=" match_parent " android:layout_height=" match_parent " android:o rientation= "vertical" > <progressbar android:layout_width= "wrap_content" android:layout_ height= "Wrap_content" android:layout_gravity= "center"/> <textview android:layout_width= " Match_parent " android:layout_height=" wrap_content " android:gravity=" center " android:text=" virus scan ... " android:textsize=" 15SP "/></linearlayout>
3. Activity dialog box
Activity code:
Package Com.example.yqqmobilesafe;import Com.example.yqqmobilesafe.db.dao.keywordinfodao;import Com.example.yqqmobilesafe.domain.keywordinfo;import Android.app.activity;import Android.os.Bundle;import Android.view.view;import Android.view.view.onclicklistener;import Android.view.window;import Android.view.windowmanager;import Android.widget.button;import Android.widget.edittext;import Android.widget.toast;public class Addkeywordsinfosdailogactivity extends Activity {protected static final int Add_key_ info_scucess = 100;private EditText et_key_words_input;//Enter the keyword private EditText et_key_words_decribe;private Button msure;//OK private Button mcancel;//Cancel public addkeywordsinfosdailogactivity () {} @Overrideprotected void OnCreate ( Bundle savedinstancestate) {super.oncreate (savedinstancestate);//Remove title Requestwindowfeature (window.feature_no_ TITLE); Remove the status bar above activity GetWindow (). SetFlags (Windowmanager.layoutparams. Flag_fullscreen, Windowmanager.layoutparams. Flag_fullscreen); SetcontentvIew (r.layout.add_keyword_info_activity); init (); Setlistener ();} private void Setlistener () {Msure.setonclicklistener (new Onclicklistener () {@Overridepublic void OnClick (View v) { Keywordinfodao dao=new Keywordinfodao (Getapplicationcontext ()); if (Et_key_words_input.gettext (). toString (). Trim () . Length () ==0) {Toast.maketext (addkeywordsinfosdailogactivity.this, "Please enter a keyword or cancel!) ",". Show (); return;} if (Et_key_words_decribe.gettext (). toString (). Trim (). Length () ==0) {Toast.maketext ( Addkeywordsinfosdailogactivity.this, "Please enter the keyword description or cancel!" ",". Show (); return;} Keywordinfo info=new keywordinfo (); Info.setkey_word_info (Et_key_words_input.gettext (). toString (). Trim ()); Info.setkey_word_decribe (Et_key_words_decribe.gettext (). toString (). Trim ());//Add the Interceptor keyword to the database Dao.addkeywordinfos ( info); Info=null;setresult (Add_key_info_scucess, Getintent ()); AddKeyWordsInfosDailogActivity.this.finish ();}}); Mcancel.setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View v) { AddKeyWordsInfosDailogActivity.this.finish ();}});} private void Init () {et_key_words_input= (EditText) Findviewbyid (r.id.et_key_words_input); Et_key_words_decribe= ( EditText) Findviewbyid (R.id.et_key_words_decribe), msure= (Button) Findviewbyid (r.id.btn_sure); mcancel= (Button) Findviewbyid (R.id.btn_cancel);} @Overrideprotected void OnDestroy () {Super.ondestroy ();}}
corresponding layout file
<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "Android:layout_width=" Match_parent "android:layout_height=" match_parent "android:background=" #ffffff " android:orientation= "vertical" > <textview android:layout_width= "match_parent" android:layout_height = "Wrap_content" android:text= "Add keyword" android:gravity= "center"/> <textview Android:layout_ma rgintop= "10DP" android:layout_width= "match_parent" android:layout_height= "wrap_content" android:text= "Please enter the need to stop Truncated keywords (up to 16 characters, allow Chinese characters, letters, numbers) "android:gravity=" center "/> <edittext android:id=" @+id/et_key_wor Ds_input "android:layout_margintop=" 5DP "android:layout_width=" Match_parent "android:layout_height=" 5 5DP "/> <edittext android:id=" @+id/et_key_words_decribe "android:layout_margintop=" 5d P "Android:layout_width="Match_parent "android:layout_height=" 55DP "android:hint=" input description "/><relativelayout Android:layout_ Width= "Match_parent" android:layout_height= "wrap_content" > <button android:id= "@+id/btn_cancel "Android:layout_width=" 160DP "android:layout_height=" 55DP "android:text=" Cancel "android:layout_alignparentleft=" True "android:background=" @drawable/sure_cancel_selector "/> <button android:id=" @+id/btn _sure "android:layout_torightof=" @+id/btn_cancel "android:layout_width=" Wrap_content "android:layout_height= "55DP" android:layout_alignparentright= "true" android:text= "determines" android:background= "@drawable/sure_cancel_select or "/> </RelativeLayout></LinearLayout>
:
android dialog Box Summary