qyxxjd / multiplestatusview Goto Github PK
View Code? Open in Web Editor NEW一个支持多种状态的自定义View,可以方便的切换到:加载中视图、错误视图、空数据视图、网络异常视图、内容视图。
License: MIT License
一个支持多种状态的自定义View,可以方便的切换到:加载中视图、错误视图、空数据视图、网络异常视图、内容视图。
License: MIT License
这一天心情也抑郁,看到表情包icon看笑了,心情也变好了,感谢
这个好像只能通过xml来设置布局,能通过代码动态添加 空 异常 内容 加载 布局吗?
这个地方,这样写是不是有点不合适,如果多次showempty 是不是会导致解析xml布局文件多次
MultipleStatusView 嵌套TwinklingRefreshLayout
<com.classic.common.MultipleStatusView
android:id="@+id/include_multiple_status_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:emptyView="@layout/custom_empty_view"
app:errorView="@layout/custom_error_view"
app:loadingView="@layout/custom_loading_view"
app:noNetworkView="@layout/custom_no_network_view"
>
<!--scrollview布局-->
<com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout
android:id="@+id/include_refreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--列表布局-->
<android.support.v7.widget.RecyclerView
android:id="@+id/include_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/headview"
android:background="#fff"
android:focusableInTouchMode="false"
android:overScrollMode="never"
android:scrollbars="none" />
</com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout>
</com.classic.common.MultipleStatusView>
然后在fragment应用 外层是viewpager+tablayout 滑动几次就会空白
更新到1.3之后,各种状态切换不过来
作者你好,我在项目中遇到这样的需求:在空视图时也可以下拉刷新,所以MultipleStatusView是放在下拉刷新库里面的,但是这样话在加载视图时也可以下拉刷新,这样会频繁触发网络请求。所以可以在加载数据显示加载视图的时候禁止其他操作吗?
showContent() 希望可以动态添加布局
和其他的一样 比如 howNoNetwork(customView, layoutParams);
在节点下面添加类似recyclerview的控件,在错误界面无法监听到重新加载的回掉
如题.....真不知道大家有遇到吗
平时测试都没有什么问题,但是在后台却收集到了很多空指针异常的问题;
java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup)' on a null object reference
at com.classic.common.MultipleStatusView.inflateView(MultipleStatusView.java)
at com.classic.common.MultipleStatusView.showEmpty(MultipleStatusView.java)
at com.classic.common.MultipleStatusView.showEmpty(MultipleStatusView.java)
MultipleStatusView是直接下载布局里面的,通过butterknife来绑定的控件;
求解答;
视图状态切换,处于重叠状态
如题,CoordinatorLayout中第一个了控件是AppBarLayout,第二个是MultipleStatusView,MultipleStatusView中的子视图无法居中
能动态给视图添加内容吗,比如动态给错误视图设置内容,显示错误原因。
setStatusHintContent重载一个, 参数 hint 支持CharSequence的.
private void setStatusHintContent(View view, CharSequence hint) {
checkNull(view, "Target view is null.");
TextView hintView = view.findViewById(R.id.status_hint_content);
if (null != hintView) {
hintView.setText(hint);
} else {
throw new NullPointerException("Not find the view ID status_hint_content
");
对于整个app都公用同样一套布局的时候,可以增加一个全局配置布局的方法,app加载时一次性配置
根据mContentView = findViewById(R.id.content_view);去设置内容视图有点不便,用起来还得把内嵌视图最外层命名为content_view,繁琐切容易重复,可以考虑内嵌视图只支持一个子视图,然后mContentView = this.getChildAt(0);去处理
一开始显示loading_view,后 再显示empty_view, loading_view没有关闭, 两个view重叠了. 没有关闭view的方法
为什么切换不同的布局,各个布局的内容都出现了,重叠了。
使用dababinding 的时候怎么找到contentView 里边的view
public RelativeLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
这个构造方法能支持一下嘛?
我在继承MultipleStatusView时,定义一个style
<style name="BaseMultipleStatusView" parent="MultipleStatusView">
<item name="emptyView">@layout/empty_view</item>
<item name="errorView">@layout/error_view</item>
<item name="loadingView">@layout/layout_loading_view</item>
<item name="noNetworkView">@layout/layout_net_offline</item>
</style>
这样就可以放到第四个参数里。(当然也可以在xml中定义style引用这个)
要是能支持第四个参数,直接在继承类中加入就更方便了,烦请大佬指点!!!
在实际使用时有时在视图切换时需要做一些操作,所以建议添加一个视图状态(ViewStatus)改变监听事件。
显示内容视图的时候,会将MultipleStatusView下的不在mOtherIds列表内的所有childView的visibale状态置为Visiable,如果原来视图有部分是需要隐藏的就会全部显示出来
在实例代码中build显示以下错误:
Error:Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.classic.common:multiple-status-view:1.4. <a href="openFile:C:/Users/Leu/Desktop/MultipleStatusView-master/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.classic.common:multiple-status-view:1.4.">Show Details</a>
在自己的代码中引用也出了类似的错。
网上搜索之后是这个原因:
http://www.jcodecraeer.com/a/anzhuokaifa/Android_Studio/2017/1026/8646.html
可是其他的库都是可以用的,就这个库不行。
实际开发中,很多空视图界面是一样的,只是提示文案信息不同,能不能做到动态设置提示文案信息,这样就不需要每次都去创建空视图了。
好早前看过一次代码,就是viewgroup添加几个view,再去判断对应的状态,其它隐藏。
显然又加了一个层次,我考虑能否在Activity或者Fragment里面用代码依据对应的网络请求动态地去改变window的内容,不必这样一个层次,作者有时间可以讨论下。
加载中不是简单的loading,而是加载xml做动画的话,是得自己集成MultipleStatusView重写showLoading方法么?
比如说登陆时,应该在上面显示一个登陆中的状态,但并不完全隐藏登陆的信息。再如请求网络的时候的,用加载中好像就不太匹配。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.