使用是布局

  <android.support.v4.widget.SwipeRefreshLayout
android:id="@id/id_swiperefreshlayout"
android:layout_width="match_parent"
android:layout_height="match_parent" > <android.support.v7.widget.RecyclerView
android:id="@id/id_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:cacheColorHint="@null"
android:scrollbars="vertical" />
</android.support.v4.widget.SwipeRefreshLayout>
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
mRecyclerview.setLayoutManager(layoutManager);
adapter = new BroadcastRecyclerViewAdapter(context, list,userModel);
mRecyclerview.setAdapter(adapter);
mSwipeRefreshWidget.setColorSchemeColors(R.color.btn_blue_normal,R.color.btn_blue_pressed);
mSwipeRefreshWidget.setOnRefreshListener(new OnRefreshListener() { @Override
public void onRefresh() {
mType=1;page=1;
initData();
}
});

RecyclerView.Adapteret用户

public class BroadcastRecyclerViewAdapter extends RecyclerView.Adapter<BroadcastViewHolder> {
public LayoutInflater mLayoutInflater;
List<BroadcastDetailsModel> mDatas;
private Context mContext;
UserDetails userModel;
BroadcastAPI broadcastApi;
private IOnItemClickListener<BroadcastDetailsModel> onItemClickListener;
public BroadcastRecyclerViewAdapter(Context context,
List<BroadcastDetailsModel> datas,UserDetails userModel){
mLayoutInflater=LayoutInflater.from(context);
this.mDatas=datas;
mContext=context;
this.userModel=userModel;
broadcastApi=new BroadcastAPI();
} // 点击事件接口
public interface OnItemClickListener {
void onItemClick(View view, int position,BroadcastDetailsModel model); void onItemLongClick(View view, int position,BroadcastDetailsModel model);
} public OnItemClickListener mOnItemClickListener; public void setOnItemClickListener(OnItemClickListener listener) {
this.mOnItemClickListener = listener;
} public void addItemLast(List<BroadcastDetailsModel> datas) {
mDatas.addAll(datas);
} public void addItemTop(List<BroadcastDetailsModel> datas) {
mDatas = datas;
} @Override
public int getItemCount() {
return mDatas==null?0:mDatas.size();
} @Override
public void onBindViewHolder(final BroadcastViewHolder holder, final int position) {
final BroadcastDetailsModel model=mDatas.get(position);
int type = getItemViewType(position);
//点击事件在这里实现,主要是利用RecyclerView中填充的布局控件可以被点击这个原理
if (mOnItemClickListener != null) {
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mOnItemClickListener.onItemClick(holder.itemView, position,model);
}
}); // 长点击事件
holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
mOnItemClickListener.onItemLongClick(holder.itemView, position,model);
return true;
}
}); }
holder.text_loaction.setVisibility(View.VISIBLE);
holder.text_loaction.setText(model.getProvince() + ","+ model.getCity());
} @Override
public BroadcastViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View mView=null;
BroadcastViewHolder mViewHolder=null;
mView = mLayoutInflater.inflate(R.layout.broadcast_fragment_item, parent, false);
mViewHolder = new BroadcastViewHolder(mView);
return mViewHolder;
} public class BroadcastViewHolder extends RecyclerView.ViewHolder {
@Bind(R.id.img_icon)
public RoundImageView img_icon;
@Bind(R.id.text_loaction)
public CustomTextView text_loaction;
public BroadcastViewHolder(View view) {
super(view);
ButterKnife.bind(this, view);
}
}

这里只实现了刷新还没有实现上拉加载更多,这里主要是记录下引用android-support-v7-recyclerview.jar 遇到的问题,刚开始我引用 了sdk\extras\android\support\v7\recyclerview\libs下的jar包

运行后提示我找这个类 在网上找了很多有说v4和v7包不一至,我换了sdk\extras\android\support文件夹下的 v4和v7依然没能解决,网上有人说用

sdk\extras\android\m2repository\com\android\support\recyclerview-v7\[版本号]  选择版本号 打开后找到recyclerview-v7-21.0.0.aar 然后解压 找到class.jar然后我将名字改为android-support-v7-recyclerview.jar

我试了 21 ,22,22.2,23.0版本都不行,我的开发环境是eclipse sdk 5.1.1

最后没办法我将sdk\extras\android\support\v7\recyclerview 项目导入到eclipse工程中 然后设置成类库 然后项目引用这个类型 在次运行 就没问题了

不知道是什么原因或者说自带的jar包是不是少什么东西,一直没解决如果有解决的或是什么原因引用的还望告知^0^

SwipeRefreshLayout 和RecyclerView 使用的更多相关文章

  1. SwipeRefreshLayout和RecyclerView滑动冲突的解决

    做了个项目,用了support包里的SwipeRefreshLayout和RecyclerView.两者一起使用有一点点小问题,有时候拉着拉着,列表还没拉玩就出来刷新的图标了,在华为荣耀上尤为明显. ...

  2. 使用SwipeRefreshLayout和RecyclerView实现仿“简书”下拉刷新和上拉载入很多其它

    一.概述 本篇博客介绍的是怎样使用SwipeRefreshLayout和RecyclerView实现高仿简书Android端的下拉刷新和上拉载入很多其它的效果. 依据效果图能够发现,本案例实现了例如以 ...

  3. SwipeRefreshLayout和RecyclerView类

    1 SwipeRefreshLayout和RecyclerView之间的关系 内容栏上下滚动是RecyclerView控制的,只有当内容栏滑动到最顶上时,再也拉不动了的时候,这个时候将动作交给Swip ...

  4. 【FastDev4Android框架开发】RecyclerView完全解析之下拉刷新与上拉加载SwipeRefreshLayout(三十一)

    转载请标明出处: http://blog.csdn.net/developer_jiangqq/article/details/49992269 本文出自:[江清清的博客] (一).前言: [好消息] ...

  5. RecyclerView再封装

    RecyclerView做为ListView的替代品,已经出了很久了,既然是替代品,那自然有些ListView没有的优点.比如说:可以随意切换list,grid,stagger.可以指定一个或多个it ...

  6. scrollview嵌套下拉控件嵌套recyclerview(不动第三方原基础自定义)

    相信会碰到很多类似的需求,一个列表控件,然后控件上方的一个头部需要自定义,这样就不好有时候也不能加在列表控件的头部了,那必须得嵌套一层scrollview了,没毛病,那么一般的列表控件都是有上拉下拉的 ...

  7. 手把手教你实现Android RecyclerView上拉加载功能

    摘要 一直在用到RecyclerView时都会微微一颤,因为一直都没去了解怎么实现上拉加载,受够了每次去Github找开源引入,因为感觉就为了一个上拉加载功能而去引入一大堆你不知道有多少BUG的代码, ...

  8. Recyclerview 实现上拉加载更多

    LinearLayoutManager layoutManager; layoutManager = new LinearLayoutManager(getActivity()); layoutMan ...

  9. RecyclerView下拉刷新上拉加载更多

    现在Android里都建议用RecyclerView代替ListView和GridView,所以下拉刷新和上拉加载更多也需要实现.下拉刷新可以用SwipeRefreshLayout 包裹Recycle ...

随机推荐

  1. 《DSP using MATLAB》Problem 6.4

    结论: 正常直接II型流图和转换直接I型非常相似:正常直接I型流图和转换直接II型非常相似.

  2. 《DSP using MATLAB》Problem 5.27

    代码: %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Outp ...

  3. hdu3336 Count the string 扩展KMP

    It is well known that AekdyCoin is good at string problems as well as number theory problems. When g ...

  4. 监控页面后退前进,浏览器文档加载事件之pageshow、pagehide

    https://www.cnblogs.com/milo-wjh/p/6811868.html http://www.runoob.com/jsref/event-onpageshow.html on ...

  5. Go Example--指针

    package main import ( "fmt" ) func zeroval(ival int) { ival = 0 } func zeroptr(iptr *int) ...

  6. GoLand tool tips

    goland format code (on save ) preference -> tool -> file watcher  then ,select go fmt 2, highl ...

  7. <------------------字符流--------------------->

    FileWriter 字符输出流: 方法: 写入:write 刷新:flush public static void main(String[] args) throws IOException { ...

  8. ksonnet 一个简化编写以及部署kubernetes的工具

    ksonnet 是一个基于jsonnet的快速简化kubernetes yaml 配置的工具,可以实现配置的复用 同时也包含一个registry 的概念,可以实现可复用组件的分发,同时支持helm 环 ...

  9. super and this

    super 指向父类的一个指针, 引用父类中的属性,方法或者构造函数 public class Father { String name ; Father(String myName){ name = ...

  10. 在HTML中导入外部的css

    1,标签:<link type="text/css" rel="stylesheet" href="CSS样式文件的绝对地址"> ...