##CommonAdapter Android RecyclerView ??Adapter???????????????Adapter. ###????
-
????
??????
build.gradle
????allprojects { repositories { ... maven { url 'https://jitpack.io' } } }
?app?
build.gradle
??????dependencies { compile 'com.github.fccaikai:CommonAdapter:0.2.0' }
-
???
????????
mRecyclerView.setAdapter(new CommonAdapter<String>(initData(),R.layout.item_text){ @Override protected void setupViewHolder(RecyclerViewHolder holder, int position, String item) { //??getView ?????View holder.getView(R.id.xxx); } } );
-
????????
adapter = new CommonAdapter<String>(R.layout.item_text) { @Override protected void setupViewHolder(RecyclerViewHolder holder, int position, String item) { //TODO } } ; mRecyclerView.setAdapter(adapter); adapter.init(initData());
-
??????
//add item click listener adapter.addOnItemClickListener(new CommonAdapter.OnItemClickListener() { @Override public void onItemClick(int position) { } } );
-
??????
//add item long click listener adapter.addOnItemLongClickListener(new CommonAdapter.OnItemLongClickListener() { @Override public void onItemLongClick(int position) { } } );