StatusView
Android 空頁面|錯誤頁面|加載中頁面處理亲善,支持所有的布局,使用簡單方便
網(wǎng)絡(luò)錯誤情況
加載中情況
數(shù)據(jù)為空情況
正常顯示內(nèi)容
去設(shè)置網(wǎng)絡(luò)
使用步驟
1.根據(jù)實際需求實現(xiàn)StatusView
繼承StatusView基類掩浙,實現(xiàn)各個頁面的初始化,這樣做的好處是我么你可以根據(jù)不同的需求夜焦,創(chuàng)建不同的加載頁面或者其他頁面的樣式虹蓄。也可以根據(jù)實際開發(fā)需求對各個頁面進行不同的出來池凄,比如枣察,加載頁面加載樣式的不同,數(shù)據(jù)為空的頁面砰盐,根據(jù)不同的調(diào)用模塊 闷袒,顯示不同的內(nèi)容。 可以只需要創(chuàng)建一次岩梳,全局使用囊骤。
Paste_Image.png
2.創(chuàng)建StatusLayout對象
方法一:強烈推薦,直接在代碼中使用就可以蒋腮。
StatusLayout statusLayout;
statusLayout =new StatusLayout.Builder()
.setContentView(contentView)//設(shè)置正常顯示內(nèi)容的VIEW
.setStatusView(statusView)
.build();
方式二:首先在XML布局中使用淘捡,然后再activity里像正常的空間
<com.bubu.status.StatusLayout
android:id="@+id/status_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ef5464">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="正常文本內(nèi)容" />
</LinearLayout>
</com.bubu.status.StatusLayout>
StatusLayout statusLayout;
statusLayout = (StatusLayout) findViewById(R.id.status_layout);
statusLayout.setStatusView(statusView);//設(shè)置statisView
3.使用StatusLayout
statusLayout.showLoading();
statusLayout.showEmpty();
statusLayout.showContent();
statusLayout.showRetry();
statusLayout.showSetting();
用起來很方便吧,一些比較常用的VIEW 池摧,DEMO里寫了一個MyStatusView.
大家可以從這里下載https://github.com/bubula/StatusView/tree/master#statusview
暫時大家只能把library下面的文件拷貝出來使用焦除,等弄好jcenter,就可以直接引用使用了
status