recycleView通用Adapter
public class CreditManagerAdapter extends RecyclerView.Adapter
private Context mContext;
private List
private final LayoutInflater mLayoutInflater;
private MyItemClickListener mItemClickListener;
public CreditManager getDataItem(int position) {
return datas == null ? null : datas.get(position);
}
public CreditManagerAdapter(Context mContext, List
this.mContext = mContext;
this.datas = mDatas;
mLayoutInflater = LayoutInflater.from(mContext);
}
public void update(List
this.datas = mDatas;
//this.notifyDataSetChanged();
}
public void notifyData(List
this.datas = mDatas;
this.notifyDataSetChanged();
}
public int getLayout() {
return R.layout.creditmanager_dialog_item;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(getLayout(), parent, false);
RecyclerView.ViewHolder viewHolder = new ViewHolder(v, mItemClickListener);
return viewHolder;
}
public void setOnItemClickListener(MyItemClickListener listener) {
mItemClickListener = listener;
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int p) {
final ViewHolder mHolder = (ViewHolder) holder;
CreditManager data = datas.get(p);
}
@Override
public int getItemCount() {
return datas == null ? 0 : datas.size();
}
public interface MyItemClickListener {
public void OnClickListener(int position);
}
static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
private MyItemClickListener mItemClickListener;
ViewHolder(View view, MyItemClickListener mItemClickListener) {
super(view);
ButterKnife.bind(this, view);
this.mItemClickListener = mItemClickListener;
view.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (mItemClickListener != null) {
mItemClickListener.OnClickListener(getPosition());
}
}
}
}
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/4560/viewspace-2813777/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- RecyclerView-->通用的AdapterViewAPT
- ListView 通用 Adapter 封裝ViewAPT封裝
- Kotlin 寫一個通用Adapter (二)KotlinAPT
- Kotlin 打造一個RecyclerView的通用Adapter(一)KotlinViewAPT
- 通過Data Binding為RecyclerView打造通用AdapterViewAPT
- 為RecyclerView打造通用Adapter 讓RecyclerView更加好用ViewAPT
- 打造基於Databinding與RecyclerView的通用Adapter類ViewAPT
- RecycleView 使用小結View
- RecycleView:再見前任(Listview)View
- Android RecycleView原始碼分析AndroidView原始碼
- AdapterAPT
- RecyclerView Adapter 系列(1):RecyclerView Array AdapterViewAPT
- Android TV開發總結【RecycleView】AndroidView
- Adapter PatternAPT
- 通用RecylerAdapter,內建XRecyclerView,相容上下拉與動畫,高複用,一個Adapter通用所有頁面,支援空頁面,懶人專屬APTView動畫
- android檢測卡頓問題,recycleview卡頓AndroidView
- [Android] 列表控制元件(RecycleView,GridView)Android控制元件View
- 安卓開發中RecycleView簡單使用步驟安卓View
- RecycleView自定義ItemDecoration,實現時間軸效果View
- 【Android Adapter】是時候開啟Adapter新時代了AndroidAPT
- RecyclerView Adapter 優雅封裝,一個Adapter搞定所有列表ViewAPT封裝
- design pattens - adapterAPT
- Adapter最佳實踐APT
- Oracle SOA Suite: AdapterOracleUIAPT
- 記一次失敗的RecycleView滑動定位View
- 通過Behavior在RecycleView中隱藏顯示FABView
- 使用RecycleView實現無限滾動的日曆View
- Istio Mixer Adapter開發 (三)自定義Mixer Grpc Adapter部署APTRPC
- VirtualBox Host-only Adapter,Failed to create the host-only adapter 轉APTAI
- Androidlistview與adapter用法AndroidViewAPT
- 用例子來弄懂AdapterAPT
- 設計模式---Adapter模式設計模式APT
- ListView(2)——自定義AdapterViewAPT
- Disk arrary's adapter in troubleAPT
- 介面卡模式(Adapter)模式APT
- Adapter中getView的理解!APTView
- FloatingActionButton在RecycleView中滑動隱藏顯示View
- 短影片app原始碼,日常開發之RecycleView滑動APP原始碼View