ActionBar-PullToRefresh的使用

转载请注明出处:http://blog.csdn.net/itachi85/article/details/41246039

下载第三方控件和所需的资源

ActionBar-PullToRefresh:https://github.com/chrisbanes/ActionBar-PullToRefresh

SmoothProgressBar:https://github.com/castorflex/SmoothProgressBar

导入SmoothProgressBar

下面有两个文件夹 java 和 res,java里面有一个fr文件夹扔到你的项目里,res里面有两个value的文件夹,把里面的xml文件稍微改下名字扔到项目中。


在这里我把包名改了,前面加上了com


导入ActionBar-PullToRefresh

目录下面有4个文件,将extras,library的java文件夹中的内容扔进项目里,res中的xml改下名字扔到项目中。


在这里我把包名改了,前面加上了com

使用控件

参考samples下面的ListViewActivity:\ActionBar-PullToRefresh-master\ActionBar-PullToRefresh-master\samples\actionbarcompat\src\java\uk\co\senab\actionbarpulltorefresh\samples\actionbarcompat

我的使用:

private void initRefreshview(View view) {
		ViewGroup viewGroup = (ViewGroup) view;
		mPullToRefreshLayout = new PullToRefreshLayout(viewGroup.getContext());
		ActionBarPullToRefresh
				.from(getActivity())
				// We need to insert the PullToRefreshLayout into the Fragment's
				// ViewGroup
				.insertLayoutInto(viewGroup)
				// Here we mark just the ListView and it's Empty View as
				// pullable
				.theseChildrenArePullable(R.id.lv_dynamic, android.R.id.empty)
				.listener(this).setup(mPullToRefreshLayout);
	}

把initRefreshow()方法放入oncreat()或者onViewCreated()方法中就行,改变你需要监听滑动的区域,我这里是R.id.lv_list和android.R.id.emptyf\分别代表listview和界面空白。


  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值