MultiStateView
![Method and size](https://img.shields.io/badge/Methods and size-64 | 7 KB-e91e63.svg)
?? Kennyc1012/MultiStateView??????,1.0???????????????,?????????????????
2.0?????,??????????,??,????????
??????View?????,???? Content
, Empty
, Fail
, Loading
4???,??????????
??? Loading
????????????????????? Loading
??????
Using MultiStateView
Layout
<me.xdj.view.SimpleMultiStateView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:xdj="http://schemas.android.com/apk/res-auto"
android:id="@+id/multi_state_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
xdj:msv_emptyView="@layout/msv_view_state_empty"
xdj:msv_failView="@layout/msv_view_state_fail"
xdj:msv_loadingView="@layout/msv_view_state_loading"
tools:context="me.xdj.multistateview.MainActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="Content" /> </me.xdj.view.SimpleMultiStateView>
??????????????????
<attr name="msv_loadingView" format="reference" /> <attr name="msv_emptyView" format="reference" /> <attr name="msv_failView" format="reference" />
Tips
??MultiStateView
???FrameLayout
,??????????,??????.
????
public void setViewState(int state) // ?????? public int getViewState()
// ?????? public View getView(int state)
// ????????? public void addViewForStatus(int status, int resLayoutID) // ???? public void setOnInflaterListener(OnInflateListener onInflateListener) // ???Layout inflate???(??CONTENT)
Tips
- ??
Loading
??????????,??Loading
?????? 600ms???? 600ms??- ??
CONTENT
????? Layout???????setViewState
??? inflate,?????????????????????,????setOnInflaterListener
????
??
public static final int STATE_CONTENT = 10001; public static final int STATE_LOADING = 10002; public static final int STATE_EMPTY = 10003; public static final int STATE_FAIL = 10004;
??
??????? MultiStateFragment
Including in your project
?? MultiStateView????????????? build.gradle
Add repository
repositories {
maven {
url 'https://jitpack.io'
}
}
Add dependency
dependencies {
compile 'com.github.XuDaojie:MultiStateView:v2.2.3'
}
???????
Kennyc1012/MultiStateView
android.support.v4.widget.ContentLoadingProgressBar
License
Copyright XuDaojie
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.