RecyclerView点击切换布局

//在开始写上
int chenge=0;
//点击事件中写
if( chenge== 0){ // 添加分割线 recyclerView.addItemDecoration( new Rc_ItemDecoration(search_homeActivity. this)); // 布局管理器 LinearLayoutManager llm= new LinearLayoutManager(search_homeActivity. this); recyclerView.setLayoutManager(llm); //改变
  chenge= 1;} else if( chenge== 1){ GridLayoutManager gridLayoutManager = new GridLayoutManager(search_homeActivity. this, 2); recyclerView.setLayoutManager(gridLayoutManager);
 //再改回去
  chenge= 0;}
recyclerView.setAdapter(mda);
//在请求网络数据中写的

你可能感兴趣的:(RecyclerView点击切换布局)