-2
This is what I am trying to build如何转换列表视图内部的网格视图片段?
我不知道如何使用的ImageButton或标签做到这一点。我可以在运行时更改碎片的布局吗?或者我应该使用2个不同的片段?
This is what I am trying to build如何转换列表视图内部的网格视图片段?
我不知道如何使用的ImageButton或标签做到这一点。我可以在运行时更改碎片的布局吗?或者我应该使用2个不同的片段?
您必须使用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);
这是一个卡视图,您要查看在您的屏幕截图回收视图。在google上搜索卡片视图和回收站视图,你会发现许多教程来实现这一目标。 – Akshay