5
I made two buttons that set Adapter in recyclerview, each arrow button a different layout, but only doing so
findViewById(R.id.layout2).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
recyclerView adapter = new recyclerView(R.layout.listlayout);
RecyclerView rv = findViewById(R.id.rv);
adapter.notifyDataSetChanged();
rv.swapAdapter(adapter,true);
rv.setLayoutManager(new LinearLayoutManager(v.getContext()));
}
});
didn’t work, he only arrow once, in case you want to change the layout it doesn’t change, I tried too
Intent main = new Intent(MainActivity.this,MainActivity.class);
finish();
startActivity(main);
But in doing so, he arrow the Adapter and reboot, thus losing the Adapter. I wonder if anyone has another way to do that.