This is what I am trying to build
我不知道如何使用 ImageButton 或标签来执行此操作。我可以在运行时更改片段的布局吗?或者我应该使用2个不同的片段?
答案 0 :(得分:-1)
您必须使用RecyclerView
并为listView设置其布局管理器。使用LinearLayoutManager
,对于网格视图,您必须使用GridLayoutManager
RecyclerView recyclerview = (RecyclerView) findViewById(R.id.recyclerview);
//this is for list view
// LinearLayoutManager mLayoutManager = new LinearLayoutManager(this);
//this is fro grid view
GridLayoutManager mLayoutManager = new GridLayoutManager(this, 2);
recyclerview.setLayoutManager(mLayoutManager);