android 加载多种状态,Android-MultiStateView

MultiStateView

处理以数据为中心的视图的多个显示状态内容状态;显示视图的内部内容( 如在XML中定义的那样)

加载状态;显示加载状态( 通过 loadingLayout 属性指定,或者通过默认布局( res/layout/msv__loading.xml ) 显示加载状态

以下示例显示了以加载,一般错误,网络错误,以及按顺序显示的内容( 使用默认布局) 状态的示例。

sample_loading.png

sample_general_error.png

sample_network_error.png

sample_content.png

用法对于任何你想用处理的View,在 MultiStateView node 中封装 View。

在代码中,通过 MultiStateView#getContentView() 获取 MultiStateView的子元素,并根据需要转换该值。 没有什么理由把 android:id 放在子 View 上。

示例假设你从以下位置开始:

你最终应该有类似的东西:

android:id="@+id/list_container"android:layout_width="match_parent"android:layout_height="match_parent">

示例笔记 0. android:id="@+id/list" 已经从 ListView 移动到 MultiStateView 0. 它还被重命名为 list_container,以注意它现在是 ListView 0的父元素。 代码中的任何引用现在都应该使用 MultiStateView#getContentView() 转换为 ListView 来引用 ListView 子元素。 没有什么理由把 id 放在 ListView 上。 请参见下面。在代码中ListView list = (ListView) findViewById(R.id.list);变成MultiStateView container = (MultiStateView) findViewById(R.id.list_container);ListView list = (ListView) container.getContentView();若要控制 MultiStateView的状态,请使用 MultiStateView#setState(State) 方法。container.setState(State.LOADING);默认情况下,"装入"指示使用库( res/layout/msv__loading.xml ) 中提供的加载布局。 要自定义,可以使用对布局的引用将自定义属性 msvLoadingLayout 添加到XML中,并对布局进行引用以增加。

贡献者Dallas?

许可证

Apache 2.0Copyright 2013 MeetMe, Inc.

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.

要做出贡献,fork 这个存储库,提交你的更改,并提交请求请求。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值