我创建了一个画廊,它以水平 View 显示了很多图像。
下面的每张图片都需要 3 个按钮。我不知道如何创建它。
如何实现这种布局?
这是我预期的设计:
最佳答案
您可以有一个自定义的 ListView
,每个元素的布局都有图像和按钮。为此,您需要子类化 BaseAdapter
并将此适配器注入(inject)您的 ListView
。
final BaseAdapter myCustomAdapter = new GalleryAdapter(this);
final ListView gallery = (ListView) findViewById(R.id.gallery);
gallery.setAdapter(myCustomAdapter);
public class GalleryAdapter extends BaseAdapter {
....
implements the class
....
}
适配器中的 getView
方法将为单个项目生成布局,并用您想要的内容动态填充它。
关于android - 如何合并图库中每个图像的按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8092689/