Http://blog.csdn.net/wangqilin8888/article/details/7464806
When we use toaster as a prompt in an application, we find such a problem. When a condition server is used, the toaster dialog box will pop up and this condition will be executed continuously, toaster will not stop. show: the display is displayed several times after execution. Even if the application exits, the toast will not stop. show, this will bring a poor user experience. When we exit the application, we should not display toast. Show.
We can implement toaster. Cancel () when the application exits ondestroy (), but toaster must be global, the same toaster
[Java] View plaincopyprint?
-
- Mtoast = new toast (this); // oncreate ()
-
- Layoutinflater Inflater = layoutinflater. From (this );
-
- View view2 = Inflater. Inflate (R. layout. toAs, null );
-
- Mtoast. setview (view2 );
-
- Mtoast. setduration (1000 );
-
-
- Create a layoutinflater, which includes:
-
- <Linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android"
-
- Android: Orientation = "vertical" Android: layout_width = "wrap_content"
-
- Android: layout_height = "wrap_content">
- <Textview Android: layout_width = "wrap_content"
-
- Android: Background = "# ff000000"
-
- Android: layout_height = "wrap_content" Android: text = "@ string/most_char"/>
-
-
- </Linearlayout>
You can control toaster. Show by following the preceding steps.