The first is to create a new dialog XML file.
1 <?XML version= "1.0" encoding= "Utf-8"?>2 <LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"3 Android:layout_width= "Wrap_content"4 Android:layout_height= "Wrap_content"5 Android:background= "@drawable/ic_loading_bg"6 android:gravity= "Center"7 android:orientation= "vertical"8 android:padding= "16.0dip" >9 Ten <ProgressBar One Android:layout_width= "24.0dip" A Android:layout_height= "24.0dip" - android:indeterminatedrawable= "@drawable/progress_drawable_white" /> - the <TextView - Android:id= "@+id/id_tv_loadingmsg" - Android:layout_width= "Wrap_content" - Android:layout_height= "Wrap_content" + android:layout_gravity= "Center_vertical" - Android:layout_margintop= "8.0dip" + Android:textcolor= "@color/white" A android:textsize= "16.0dip" /> at - </LinearLayout>
IC_LOADING_BG is a picture of a background. The Progress_drawable_white.xml file in the drawable above is as follows,
<?XML version= "1.0" encoding= "Utf-8"?><animation-listAndroid:oneshot= "false"xmlns:android= "Http://schemas.android.com/apk/res/android"> <Itemandroid:duration= "The "android:drawable= "@drawable/ic_loading_white_01" /> <Itemandroid:duration= "The "android:drawable= "@drawable/ic_loading_white_02" /> <Itemandroid:duration= "The "android:drawable= "@drawable/ic_loading_white_03" /> <Itemandroid:duration= "The "android:drawable= "@drawable/ic_loading_white_04" /> <Itemandroid:duration= "The "android:drawable= "@drawable/ic_loading_white_05" /> <Itemandroid:duration= "The "android:drawable= "@drawable/ic_loading_white_06" /> <Itemandroid:duration= "The "android:drawable= "@drawable/ic_loading_white_07" /> <Itemandroid:duration= "The "android:drawable= "@drawable/ic_loading_white_08" /> <Itemandroid:duration= "The "android:drawable= "@drawable/ic_loading_white_09" /> <Itemandroid:duration= "The "android:drawable= "@drawable/ic_loading_white_10" /> <Itemandroid:duration= "The "android:drawable= "@drawable/ic_loading_white_11" /> <Itemandroid:duration= "The "android:drawable= "@drawable/ic_loading_white_12" /></animation-list>
These 12 are all pictures.
The core display wait box code is as follows,
ProgressDialog = new Dialog (aboutactivity.this,r.style.progress_dialog);p Rogressdialog.setcontentview ( r.layout.progress);p Rogressdialog.getwindow (). Setbackgrounddrawableresource (Android. R.color.transparent); TextView msg = (TextView) Progressdialog.findviewbyid (r.id.id_tv_loadingmsg); Msg.settext ("Hard loading"); Progressdialog.show ();
The text can be changed by itself, convenient and direct.
Tips for beginners, remember to write the private Dialog progressdialog at the beginning; (the veteran can ignore this.)
There is a style, add the following code to the Style.xml file inside the OK!
<stylename= "Progress_dialog"Parent= "@android: Style/theme.dialog"> <Itemname= "Android:windowframe">@null</Item> <Itemname= "Android:windowisfloating">True</Item> <Itemname= "Android:windowistranslucent">True</Item> <Itemname= "Android:windownotitle">True</Item> <Itemname= "Android:background">@null</Item> <Itemname= "Android:windowbackground">@null</Item> <Itemname= "android:backgrounddimenabled">False</Item> </style>
about how to make this disappear, where the need to disappear is added
Progressdialog.dismiss ();
dialog dynamic load diagram. rar
Android based on dialog implementation wait loading box