让loading的各种状态切换显示变得简单化..
compile 'me.rawnhwang.library:app:1.2.5'
Firtst of,get a SmartLoadingLayout(DefaultLoadingLayout/CustomLoadingLayout) object
If we select DefaultLoadingLayout
private DefaultLoadingLayout mLayout;
//......
ListView lvContent = (ListView) findViewById(R.id.lv_content);
mLayout = SmartLoadingLayout.createDefaultLayout(this,lvContent);
When called onLoading
mLayout.onLoading();
When called onDone
mLayout.onDone();
When called onEmpty
mLayout.onEmpty();
When called onError
mLayout.onError();
if you don't like the original style,you can turn them into the way you like
for example:
mLayout.setErrorButtonListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mLayout.replaceErrorIcon(R.mipmap.ic_launcher);
mLayout.setErrorDescription("This my error information.");
mLayout.setErrorDescriptionColor(Color.BLUE);
mLayout.setErrorDescriptionTextSize(20);
mLayout.setErrorButtonText("oh!no!");
mLayout.setErrorButtonTextColor(Color.RED);
mLayout.setErrorButtonBackground(R.drawable.bg_error);
}
});
Android if you want to totally customize,youc can use CustomLoadingLayout
for example:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView
android:id="@+id/lv_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true" />
<!-- this is your custom part -->
<include
android:id="@+id/my_empty_page"
layout="@layout/my_empty_page" />
<include
android:id="@+id/my_error_page"
layout="@layout/my_error_page" />
<include
android:id="@+id/my_loading_page"
layout="@layout/my_loading_page" />
</LinearLayout>
private CustomLoadingLayout mLayout;
//.........
mLayout = SmartLoadingLayout.createCustomLayout(this);
mLayout.setContentView(R.id.lv_content);
mLayout.setLoadingView(R.id.my_loading_page);
mLayout.setEmptyView(R.id.my_empty_page);
mLayout.setErrorView(R.id.my_error_page);