Take a look at the effect
One, Load box code
Two, the dialog box code
Three, hint box code
===============1
Package Com.idonoo.frame.widget;import Android.app.progressdialog;import Android.content.context;import Android.os.bundle;import Android.text.textutils;import Android.view.view;import Android.widget.TextView;import com.idonoo.frame.r;/** * Contrast, the use of black background is quite a bit. * @author Intbird * */public class Progressdialogbar extends ProgressDialog {private String message;public PROGRESSDIALOGB AR (Context context) {Super (context, r.style.customdialog);} Public Progressdialogbar (context context, String message) {Super (context, r.style.customdialog); this.message = message ;} @Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview ( R.layout.custom_progress_dialog);} @Overridepublic void Show () {show (message);} public void Show (String message) {super.show (); Textutils.isempty (message)) {TextView text = (TextView) Findviewbyid (r.id.tv_message); Text.setvisibility ( view.visible); text.settext (message);}}
<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "android:id=" @+id/linear_root "android:layout_width=" wrap_content "android:layout_height=" Wrap_content " android:background= "@drawable/dialog_bg" android:gravity= "center" android:minheight= "98DP" android:minwidth= "98 DP "android:orientation=" horizontal "> <progressbar android:id=" @+id/progress "Android:layout_wi Dth= "56DP" android:layout_height= "56DP" android:layout_gravity= "center" android:layout_margin= "15DP" android:indeterminatedrawable= "@drawable/progress_dialog" android:indeterminateduration= "1" android:m ax= "android:progress=" 0 "/> <textview android:id=" @+id/tv_message "android:layout_width = "Wrap_content" android:layout_height= "wrap_content" android:layout_marginright= "30DP" android:text= " "Android:textcolor=" #FFFFFF"Android:textsize=" 18SP "android:visibility=" Gone "/></linearlayout>
============2
Package Com.idonoo.sharecar.widget;import Com.idonoo.sharecar.r;import Android.app.dialog;import Android.app.alertdialog.builder;import Android.content.context;import Android.os.bundle;import Android.text.textutils;import Android.view.layoutinflater;import Android.view.view;import Android.view.Window; Import Android.view.windowmanager;import Android.view.windowmanager.layoutparams;import Android.widget.Button; Import android.widget.edittext;import android.widget.textview;/** * dialog box style params needs attention; * @author Intbird * */public class Myalertdialog extends Dialog {private View view;private TextView Tvtitle,tvcontent;priv Ate EditText edcontent;private Button btnyes,btncacel;public enum alertstyle{stylesingle,stylenotitle,styleinput, Styletwobutton};p rivate Context Context;public Myalertdialog (context context) {super (context,android. R.style.theme_translucent_notitlebar); this.context = Context;initview (R.layout.layout_alert_dialog);} private void Initview (int layoutid) {view= Layoutinflater.from (gEtcontext ()). Inflate (LayoutID, null); tvtitle= ((TextView) View.findviewbyid (R.id.title)); tvcontent= ((TextView) View.findviewbyid (r.id.content)); edcontent= (EditText) View.findviewbyid (r.id.ed_content); btnyes= (Button) View.findviewbyid (R.id.btn_yes); btncacel= (Button) View.findviewbyid (r.id.btn_no);} public void Inittext (String title,string content) {Tvtitle.settext (title); Tvcontent.settext (content); show ();} Public Myalertdialog (context Context,alertstyle style) {This (context), switch (style) {case Stylesingle:initview ( R.layout.layout_alert_dialog_single); break;case Stylenotitle:initview (R.layout.layout_alert_dialog_notitle); Break;case Styleinput:initview (r.layout.layout_alert_dialog_input); Break;case Styletwobutton:initview ( R.layout.layout_alert_dialog); break;}} @Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview ( view);} public void Settextyes (String text) {btnyes.settext (text);} public void Settextno (String text) {btncacel.settext (text);} PubLic EditText Getedittext () {return edcontent;} public void Setedittext (EditText edcontent) {this.edcontent=edcontent;} @Overridepublic void Show () {super.show ();} public void Show (String title,string Content,view.onclicklistener Yes) {Inittext (title, content); Btnyes.setonclicklistener (yes);} public void Show (String title,string content,view.onclicklistener yes,view.onclicklistener cacel) {Inittext (title, content); Btnyes.setonclicklistener (yes); Btncacel.setonclicklistener (cacel);} public void Show (String title,view.onclicklistener yes,view.onclicklistener cacel) {tvtitle.settext (title); Btnyes.setonclicklistener (yes); Btncacel.setonclicklistener (Cacel); show ();} @Overridepublic void Dismiss () {Super.dismiss ();} @Overridepublic void Cancel () {Super.cancel ();} public interface inputcallback{public void Inputcallback (EditText edit);}}
=======3
protected void showtoast (int res) {//all fragments should be Initui (); <span style= "white-sp Ace:pre "></span>string s=getresources (). getString (res); <span style=" White-space:pre "> </span>showtoast (s); } protected void Showtoast (Charsequence s) { & nbsp if (! Textutils.isempty (S.tostring ())) { <span style= "White-space:pre" ></span>try{ <span style= "White-space:pre" ></span>if (toast!=null) <span style= "White-space:pre" ></span>toast.cancel (); <span style= " White-space:pre "></span>toast=new Toast (getactivity ()); <span style=" White-space:pre "></span>}catch (Exception ex) { <span style=" White-space:pre " ></span>toast=null; <span style="White-space:pre" ></span>} <span style= "White-space:pre" ></span> <span style= "White-space:pre" ></span>if (toast==null) <span style= "White-space:pre" ></span>return; <span style= " White-space:pre "></span>view view=getactivity (). Getlayoutinflater (). Inflate (R.layout.toasts, NULL); <span style= "White-space:pre" ></span>textview text= (TextView) View.findviewbyid (r.id.tv_toast); <span style= "White-space:pre" ></span> Text.settext (S.tostring ()); <span style= "White-space:pre" ></span> <span style= "White-space:pre" ></span>toast.setview (view); <span style= "White-space:pre" ></span>toast.setduration (toast.length_short); <Span style= "White-space:pre" ></span>toast.show (); } }
The simplest way to implement some of the tips in Android