Learned today, the Network load data is not loaded before the display is loading, loaded after loading four characters disappear, here to use a custom control
Tipinfolayout.java This is a custom component code copy and paste just fine
1 PackageCom.wuxianedu.wxhlcorelibrary.widget;2 3 ImportAndroid.content.Context;4 ImportAndroid.util.AttributeSet;5 ImportAndroid.view.LayoutInflater;6 ImportAndroid.view.View;7 Importandroid.widget.FrameLayout;8 ImportAndroid.widget.ImageView;9 ImportAndroid.widget.TextView;Ten One ImportCom.pnikosis.materialishprogress.ProgressWheel; A ImportCOM.WUXIANEDU.WXHLCORELIBRARY.R; - - Public classTipinfolayoutextendsFramelayout { the PrivateProgresswheel Mpbprogressbar; - PublicImageView mtvtipstate; - PrivateTextView mtvtipmsg; - + Privatecontext context; - + PublicTipinfolayout (Context context) { A Super(context); at This. Context =context; - Initview (context); - } - - PublicTipinfolayout (Context context, AttributeSet attrs) { - Super(context, attrs); in This. Context =context; - Initview (context); to } + - PublicTipinfolayout (context context, AttributeSet attrs,intdefstyleattr) { the Super(context, attrs, defstyleattr); * This. Context =context; $ Initview (context);Panax Notoginseng } - the Private voidInitview (Context context) { +View view = Layoutinflater.from (context). Inflate (R.layout.core_tip_info_layout,NULL,false); AMpbprogressbar =(Progresswheel) View.findviewbyid (r.id.tv_tip_loading); theMtvtipstate =(ImageView) View.findviewbyid (r.id.tv_tip_state); +Mtvtipmsg =(TextView) View.findviewbyid (r.id.tv_tip_msg); - setloading (); $ //completeloading (); $ AddView (view); - } - the /*Public void Setonclick (Onclicklistener onclik) { - This.setonclicklistener (Onclik);Wuyi }*/ the - Public voidsetloading () { Wu setloading (context.getstring (r.string.tip_loading)); - } About $ Public voidsetloading (String message) { - //this.setvisibility (VISIBLE); - This. mpbprogressbar.setvisibility (view.visible); - This. mtvtipstate.setvisibility (view.gone); A This. mtvtipmsg.setvisibility (view.visible); + This. Mtvtipmsg.settext (context.getstring (r.string.tip_loading)); the } - $ /** the * Complete Loading the */ the Public voidcompleteloading () { the This. mpbprogressbar.setvisibility (view.gone); - This. mtvtipstate.setvisibility (view.gone); in This. mtvtipmsg.setvisibility (view.gone); the } the About Public voidSetnetworkerror () { the This. mpbprogressbar.setvisibility (view.gone); the This. mtvtipstate.setvisibility (view.visible); the This. Mtvtipstate.setimageresource (r.drawable.core_page_icon_network); + This. mtvtipmsg.setvisibility (view.visible); - This. Mtvtipmsg.settext (context.getstring (R.string.tip_load_network_error)); the }Bayi the Public voidsetloaderror (String message) { the setloaderror (); - This. Mtvtipmsg.settext (message); - } the the Public voidSetloaderror () { the This. mpbprogressbar.setvisibility (view.gone); the This. mtvtipstate.setvisibility (view.visible); - This. Mtvtipstate.setimageresource (r.drawable.core_page_icon_loaderror); the This. mtvtipmsg.setvisibility (view.visible); the This. Mtvtipmsg.settext (context.getstring (R.string.tip_load_error)); the }94 the Public voidsetemptydata (String message) { the Setemptydata (); the This. Mtvtipmsg.settext (message);98 } About - Public voidSetemptydata () {101 This. setvisibility (VISIBLE);102 This. mpbprogressbar.setvisibility (view.gone);103 This. mtvtipstate.setvisibility (view.visible);104 This. Mtvtipstate.setimageresource (r.drawable.core_page_icon_empty); the This. mtvtipmsg.setvisibility (view.visible);106 This. Mtvtipmsg.settext (context.getstring (R.string.tip_load_empty));107 }108 109 /** the * Do not show any hints111 */ the Public voidsetcancelshow () {113 This. mpbprogressbar.setvisibility (view.gone); the This. mtvtipstate.setvisibility (view.gone); the This. mtvtipmsg.setvisibility (view.gone); the }117}
And then we used it in the layout.
1 <?XML version= "1.0" encoding= "Utf-8"?>2 <Relativelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"3 Android:layout_width= "Match_parent"4 Android:layout_height= "Match_parent">5 6 <com. Wuxianedu.wxhlcorelibrary.widget.RefreshLayout7 Android:id= "@+id/refreshlayout"8 Android:layout_width= "Wrap_content"9 Android:layout_height= "Wrap_content">Ten <ListViewAndroid:id= "@+id/lv_liebiao" One Android:layout_width= "Match_parent" A Android:layout_height= "Match_parent" /> - </Com.wuxianedu.wxhlcorelibrary.widget.RefreshLayout> - <com. Wuxianedu.wxhlcorelibrary.widget.TipInfoLayout the Android:id= "@+id/tipinfolayout_id" - Android:layout_width= "Match_parent" - Android:layout_height= "Match_parent"/> - + - </Relativelayout>
Then initialize him in the Java file.
1 tipinfolayout = (tipinfolayout) View.findviewbyid (r.id.tipinfolayout_id);
Start loading
Tipinfolayout.setloading ();
Finish loading
Tipinfolayout.completeloading ();
Android Learning note-implementation is loading the circle, completing automatic cancellation after completion