调用方法的activity:
public class RecyclerView_onclick extends AppCompatActivity {
private RecyclerView mRecycler_view;
private mAdapter_recycler_onclick mAdapter;
private RecyclerView.LayoutManager mLayoutManager;
private ItemData mItemData;
private String[] setmTitle;
private int[] setmImgID;
private int[] setColorID;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cardview);
init_data();
mItemData = new ItemData(setmTitle,setmImgID,setColorID);
mRecycler_view = (RecyclerView) findViewById(R.id.my_recycler_view);
//设置固定大小
mRecycler_view.setHasFixedSize(false);
//使用线性布局
mLayoutManager = new LinearLayoutManager(this);
mRecycler_view.setLayoutManager(mLayoutManager);
//添加适配器
mAdapter = new mAdapter_recycler_oncl