我知道如何在单个图像视图中显示图像,但是不知道如何在列表视图中显示多个图像。
这里是您从图库中获取图库图像的代码在您的java类的onCreate方法中:
private RecyclerView recyclerView;
private GalleryBottomViewAdapter mAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
recyclerView = view.findViewById(R.id.recycler_view);
mAdapter = new GalleryBottomViewAdapter(listData);
RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(mActivity,2,GridLayoutManager.HORIZONTAL,false);
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setAdapter(mAdapter);
new LoadingGalleryImages().execute();
}
public void getGalleryImages(){
private ArrayList<GalleryBottomViewModel> listData;
listData=new ArrayList<GalleryBottomViewModel>();
final String[] columns = { MediaStore.Images.Media.DATA,
MediaStore.Images.Media._ID };
final String orderBy = MediaStore.Images.Media.DATE_ADDED + " DESC LIMIT 100";
Cursor imagecursor = mActivity.getContentResolver().query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, null,
null, orderBy);
int image_column_index = imagecursor
.getColumnIndex(MediaStore.Images.Media._ID);
int count = imagecursor.getCount();
Bitmap thumbnails = null;
String arrPath;
for (int i = 0; i <count; i++) {
imagecursor.moveToPosition(i);
int id = imagecursor.getInt(image_column_index);
int dataColumnIndex = imagecursor.getColumnIndex(MediaStore.Images.Media.DATA);
if(mActivity!=null) {
thumbnails = MediaStore.Images.Thumbnails.getThumbnail(
mActivity.getContentResolver(), id,
MediaStore.Images.Thumbnails.MICRO_KIND, null);
}
arrPath = imagecursor.getString(dataColumnIndex);
GalleryBottomViewModel model=new GalleryBottomViewModel();
model.setPath(arrPath);
model.setBitmap(thumbnails);
listData.add(model);
if(mActivity!=null) {
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
mAdapter.notifyDataSetChanged();
}
});
}
}
imagecursor.close();
Log.d("size_gallery=",listData.size()+"");
}
<html>
<head>
<style>
ul {
list-style-image: url('sqpurple.gif');
}
</style>
</head>
<body>
<h1>The list-style-image Property</h1>
<p>The list-style-image property replaces the list-item marker with an image:</p>
<ul>
<li><img src="" height="50px" width="50px></li>
<li><img src="" height="50px" width="50px></li>
<li><img src="" height="50px" width="50px></li>
</ul>
</body>
</html>