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
- Kotlin 寫一個通用Adapter (二)KotlinAPT
- Kotlin 打造一個RecyclerView的通用Adapter(一)KotlinViewAPT
- Adapter PatternAPT
- Android TV開發總結【RecycleView】AndroidView
- 【Android Adapter】是時候開啟Adapter新時代了AndroidAPT
- VirtualBox Host-only Adapter,Failed to create the host-only adapter 轉APTAI
- Istio Mixer Adapter開發 (三)自定義Mixer Grpc Adapter部署APTRPC
- FloatingActionButton在RecycleView中滑動隱藏顯示View
- android檢測卡頓問題,recycleview卡頓AndroidView
- 介面卡模式(adapter pattern)模式APT
- Adapter-介面卡模式APT模式
- IP Adapter程式碼筆記APT筆記
- Canal adapter 同步 ElasticSearch 記錄APTElasticsearch
- Android RecyclerView中Adapter和ViewHoAndroidViewAPT
- 通過Behavior在RecycleView中隱藏顯示FABView
- 使用RecycleView實現無限滾動的日曆View
- 記一次失敗的RecycleView滑動定位View
- 安卓開發中RecycleView簡單使用步驟安卓View
- Android:打造“萬能”Adapter與ViewHolderAndroidAPTView
- Istio Mixer Adapter開發系列 - 概述APT
- RecyclerView.Adapter的封裝(RecyclerAdapter)ViewAPT封裝
- 短影片app原始碼,日常開發之RecycleView滑動APP原始碼View
- RecyclerView的Adapter中attach和detach探索ViewAPT
- CAT Caterpillar ET Diagnostic Adapter III User ExperienceAPT
- 使用canal.adapter同步資料到MySQLAPTMySql
- recycleview聊天介面的從底部開始顯示的處理View
- app直播原始碼,RecycleView頁面的點選跳轉設計APP原始碼View
- PHP設計模式-Adapter 介面卡模式PHP設計模式APT
- Android開發——說說Adapter那點事AndroidAPT
- 微信小遊戲開發(6)-Adapter遊戲開發APT
- Lumen 報錯 : Class 'League\Flysystem\Adapter\Local' not foundAPT
- GoldenGate for Java adapter介紹二(程式碼篇)GoJavaAPT
- GoldenGate for Java Adapter介紹一(原理篇)GoJavaAPT
- 直播平臺原始碼,RecycleView實現item重疊水平滑動原始碼View
- 再也不用擔心問RecycleView了——面試真題詳解View面試
- 《設計模式》 - 5. 介面卡模式( Adapter )設計模式APT
- Scan Your Truck Using Nexiq Adapter: Simplifying Your Diagnostic ProcessAPT