UI 的适配器,在 Android Studio 的单个屏幕中结合了网格、线性布局和卡片
Adapter for UI with combination of grid, linear layout and card in a single screen in Android Studio
UI skelton of screen
我正在使用改造和 Picasso 库进行连接和图像加载。我想为上述 UI 实现一个适配器,以便可以创建动态视图并相应地向其加载图像。
我知道它们各自的适配器。
但是,如何将两者合二为一呢?
使用交错 RecyclerView。可以看看官方文档 here.
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
// set a StaggeredGridLayoutManager with 3 number of columns and vertical orientation
StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(3, LinearLayoutManager.VERTICAL);
recyclerView.setLayoutManager(staggeredGridLayoutManager); // set LayoutManager to RecyclerView
// call the constructor of YourAdapter to send the reference and data to Adapter
YourAdapter yourAdapter = new YourAdapter(MainActivity.this);
recyclerView.setAdapter(yourAdapter );
请参阅 example 开始使用
UI skelton of screen
我正在使用改造和 Picasso 库进行连接和图像加载。我想为上述 UI 实现一个适配器,以便可以创建动态视图并相应地向其加载图像。
我知道它们各自的适配器。 但是,如何将两者合二为一呢?
使用交错 RecyclerView。可以看看官方文档 here.
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
// set a StaggeredGridLayoutManager with 3 number of columns and vertical orientation
StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(3, LinearLayoutManager.VERTICAL);
recyclerView.setLayoutManager(staggeredGridLayoutManager); // set LayoutManager to RecyclerView
// call the constructor of YourAdapter to send the reference and data to Adapter
YourAdapter yourAdapter = new YourAdapter(MainActivity.this);
recyclerView.setAdapter(yourAdapter );
请参阅 example 开始使用