SwipeRefreshLayout的样式
来源:互联网 发布:大数据与电子商务 编辑:程序博客网 时间:2024/05/18 12:04
SwipeRefrshLayout是Google官方更新的一个Widget,可以实现下拉刷新的效果。该控件集成自ViewGroup在support-v4兼容包下,不过我们需要升级supportlibrary的版本到19.1以上。基本使用的方法如下:
- setOnRefreshListener(OnRefreshListener):添加下拉刷新监听器
- setRefreshing(boolean):显示或者隐藏刷新进度条
- isRefreshing():检查是否处于刷新状态
- setColorSchemeResources():设置进度条的颜色主题,最多设置四种,以前的setColorScheme()方法已经弃用了。
- 布局代码:
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${relativePackage}.${activityClass}" >
<android.support.v4.widget.SwipeRefreshLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/refresh" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="随机产生1到100的整数:" />
<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
</ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout> - 显示代码:
- public class MainActivity extends Activity
{
SwipeRefreshLayout swipeRefreshLayout;
TextView mTextView;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh);
mTextView = (TextView) findViewById(R.id.tv1);
swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener()
{
@Override
public void onRefresh()
{
// TODO Auto-generated method stub
swipeRefreshLayout.setRefreshing(true);
// swipeRefreshLayout.setColorSchemeResources();
new Handler().postDelayed(new Runnable()
{
@Override
public void run()
{
// TODO Auto-generated method stub
int mat = (int) (Math.random() * 100 + 1);
swipeRefreshLayout.setRefreshing(false);
mTextView.setText(String.valueOf(mat));
}
}, 3000);
}
});
}
} - 问题:动画样式在support library不同时有两种样式。一种是圆形,另一种是进度条(好丑)。想要是圆形,就把support升级到最新。
1 0
- SwipeRefreshLayout的样式
- android的SwipeRefreshLayout 扩展
- Android官方的SwipeRefreshLayout
- Android官方的SwipeRefreshLayout
- CoordinatorLayout、SwipeRefreshLayout的使用
- SwipeRefreshLayout的简单使用
- SwipeRefreshLayout 的简单使用
- Android SwipeRefreshLayout的使用
- SwipeRefreshLayout 的基本使用
- SwipeRefreshLayout的事件处理
- SwipeRefreshLayout的使用方法
- SwipeRefreshLayout的用法
- SwipeRefreshLayout的使用注意事项
- 简单的使用SwipeRefreshLayout
- SwipeRefreshLayout的使用详解
- SwipeRefreshLayout的简单使用
- SwipeRefreshLayout 的简单使用
- SwipeRefreshLayout
- 时域卷积频域相乘证明
- 人脸检测研究最新进展
- 求数组的所有子集
- 欢迎使用CSDN-markdown编辑器
- 【php】获取网页内容
- SwipeRefreshLayout的样式
- [LeetCode 278] First Bad Version(二分查找的一个常见注意点)
- 图片排版
- 更新SDK后ADT版本低不支持,sdk找不到问题解决方案
- Linux驱动编程day6-外部中断处理
- 初识Java反射
- 在word里操作表格
- 55.Compare Strings-比较字符串(容易题)
- linux PINCTRL