当前位置: 搜索的结果

DragSelectRecyclerView 长按滑动多选图像android特效

高仿Google相册多选效果,长按某一item后然后滑动选择到任意item,效果很不错,适合相册页面多选部分效果。
本例子主要是自定义DragSelectRecyclerView通过如下展示gridview效果
  mList = (DragSelectRecyclerView) findViewById(R.id.list);
        mList.setLayoutManager(new GridLayoutManager(this, getResources().getInteger(R.integer.grid_width)));
        mList.setAdapter(mAdapter);
 

RecyclerView加载不同view实现效果

本项目由开发者:黄洞洞精心为初学者编辑RecyclerView的使用方法。
RecyclerView加载不同view实现效果,支持加载多个view,并且支持用volley获取数据,
项目主要介绍:
初始化视图:
    mRV=(RecyclerView) findViewById(R.id.rv_basefragment);
        mRV.setLayoutManager(new LinearLayoutManager(this));


 //初始化请求队列 queue = Volley.newRequestQueue(this);
//获取网络接口
StringRequest stringRequest=new StringRequest(URL, new Response.Listener<String>() {

            @Override
            public void onResponse(String response) {
                //处理数据
                processData(response);
                
            }
        }, new Response.ErrorListener() {

            @Override
            public void onErrorResponse(VolleyError error) {
                System.out.println(error.getMessage()+"ddddddddddddddddddddddddddddddddddddddddddddd");
            }
        });
        
        //将请求加入到队列中
        queue.add(stringRequest);

 

 

//视图绑定
/*
     * onBindViewHolder 根据ViewHolder_01获取多个view
     * */
    @Override
    public void onBindViewHolder(BaseViewHolder holder, int position) {
         switch (superData.get(position).first){
         case COMMUNITY_TOP:
             ((ViewHolder_01)holder).initData(communityBean);
             break;
         case COMMUNITY_OHTER:
             ((ViewHolder_02)holder).initData(superData.get(position));
             break;
     }
    }
    
/*
     * onCreateViewHolder 根据类型绑定多个ViewHolder_01,加载多个不同view
     * */
    @Override
    public BaseViewHolder onCreateViewHolder(ViewGroup arg0, int type) {
        
        switch (type) {
        case COMMUNITY_TOP:
            return new ViewHolder_01(View.inflate(context, R.layout.item_community_top, null),context);
        case COMMUNITY_OHTER:
            return new ViewHolder_02(View.inflate(context, R.layout.item_community_other, null),context);
        }
        
        return new ViewHolder_02(View.inflate(context, R.layout.item_community_other, null),context);
    }

RecyclerView的多种使用方式

在AdapterView和RecyclerView中通用的Adapter和ViewHolder,使AdapterView和RecyclerView适配器的使用方式基本一致。
使用非常简单,这里展示一下ListView和RecyclerView实现qq聊天界面的适配器
public class ListChatAdapter extends BGAAdapterViewAdapter<ChatModel> {

    public ListChatAdapter(Context context) {
        super(context, R.layout.item_chat);
    }

    /**
     * 为item的孩子节点设置监听器,并不是每一个数据列表都要为item的子控件添加事件监听器,所以在父类中采用了空实现,需要设置事件监听器时重写该方法即可
     *
     * @param viewHolderHelper
     */
    @Override
    protected void setItemChildListener(BGAViewHolderHelper viewHolderHelper) {
    }

    @Override
    public void fillData(BGAViewHolderHelper viewHolderHelper, int position, ChatModel model) {
        if (model.mUserType == ChatModel.UserType.From) {
            viewHolderHelper.setVisibility(R.id.rl_item_chat_to, View.GONE);
            viewHolderHelper.setVisibility(R.id.rl_item_chat_from, View.VISIBLE);
            String htmlMsg = String.format(mContext.getString(R.string.color_msg_from), model.mMsg);
            viewHolderHelper.setHtml(R.id.tv_item_chat_from_msg, htmlMsg);
        } else {
            viewHolderHelper.setVisibility(R.id.rl_item_chat_from, View.GONE);
            viewHolderHelper.setVisibility(R.id.rl_item_chat_to, View.VISIBLE);
            String htmlMsg = String.format(mContext.getString(R.string.color_msg_to), model.mMsg);
            viewHolderHelper.setHtml(R.id.tv_item_chat_to_msg, htmlMsg);
        }
    }

}

RecyclerView实现qq聊天界面的适配器

public class RecyclerChatAdapter extends BGARecyclerViewAdapter<ChatModel> {
    public RecyclerChatAdapter(RecyclerView recyclerView) {
        super(recyclerView, R.layout.item_chat);
    }

    /**
     * 为item的孩子节点设置监听器,并不是每一个数据列表都要为item的子控件添加事件监听器,所以在父类中采用了空实现,需要设置事件监听器时重写该方法即可
     *
     * @param viewHolderHelper
     */
    @Override
    public void setItemChildListener(BGAViewHolderHelper viewHolderHelper) {
    }

    @Override
    public void fillData(BGAViewHolderHelper viewHolderHelper, int position, ChatModel model) {
        if (model.mUserType == ChatModel.UserType.From) {
            viewHolderHelper.setVisibility(R.id.rl_item_chat_to, View.GONE);
            viewHolderHelper.setVisibility(R.id.rl_item_chat_from, View.VISIBLE);
            String htmlMsg = String.format(mContext.getString(R.string.color_msg_from), model.mMsg);
            viewHolderHelper.setHtml(R.id.tv_item_chat_from_msg, htmlMsg);
        } else {
            viewHolderHelper.setVisibility(R.id.rl_item_chat_from, View.GONE);
            viewHolderHelper.setVisibility(R.id.rl_item_chat_to, View.VISIBLE);
            String htmlMsg = String.format(mContext.getString(R.string.color_msg_to), model.mMsg);
            viewHolderHelper.setHtml(R.id.tv_item_chat_to_msg, htmlMsg);
        }
    }

}

recyclerview-stickyheaders

recyclerview实现的头部分类(stickyheader)效果,有top和overlay两种分类显示方法。

https://github.com/eowise/recyclerview-stickyheaders

android-parallax-recyclerview

滑动actionbar渐变效果,

 

sticky-headers-recyclerview


This decorator allows you to easily create section headers for RecyclerViews using a LinearLayoutManager in either vertical or horizontal orientation.

RecyclerViewItemAnimators


This repo provides simple animators for the item views in the RecyclerView This code is cloned from DefaultItemAnimator provided by Google customizing the animations.

UltimateRecyclerView

A RecyclerView(advanced and flexible version of ListView in Android) with refreshing,loading more,animation and many other features.

Recyclerview-Sample

Sample android app for recyclerview using Linear, Grid and Staggered Grid Layout managers.

recyclerview-binder

Android Library for RecyclerView to manage order of items and multiple view types.