我一直致力于创建图像的网格视图,图像存在于Assets文件夹中.从android链接中的assets文件夹打开文件帮助我使用位图来读取它.我目前的代码是:
public View getView(final int position, View convertView, ViewGroup parent)
{
try
{
AssetManager am = mContext.getAssets();
String list[] = am.list("");
int count_files = imagelist.length;
for(int i= 0;i<=count_files; i++)
{
BufferedInputStream buf = new BufferedInputStream(am.open(list[i]));
Bitmap bitmap = BitmapFactory.decodeStream(buf);
imageView.setImageBitmap(bitmap);
buf.close();
}
}
catch (IOException e)
{
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
我的应用程序确实从Assets文件夹中读取图像,但它没有遍历网格视图中的单元格.网格视图的所有单元格具有从该组图像中拾取的相同图像.任何人都可以告诉我如何迭代细胞仍然有不同的图像?
我在ImageAdapter类中有上面的代码,它扩展了BaseAdapter类,在我的主类中,我将它与我的gridview链接:
GridView gv =(GridView)findViewById(R.id.gridview);
gv.setAdapter(new ImageAdapter(this, assetlist));
Run Code Online (Sandbox Code Playgroud)
Saran,非常感谢您提前提供任何帮助