Java android,如何通过位图找到ImageView?
假设我有一个创建ImageView并将其添加到布局的循环Java android,如何通过位图找到ImageView?,java,android,Java,Android,假设我有一个创建ImageView并将其添加到布局的循环 final LinearLayout linLayRow1 = (LinearLayout) findViewById(R.id.LLrow1); ... try { FileInputStream in1 = new FileInputStream(masterPath+shiftimage); BufferedInputStream buf1 = new BufferedInputStream(in1); Bitmap bMa
final LinearLayout linLayRow1 = (LinearLayout) findViewById(R.id.LLrow1);
...
try {
FileInputStream in1 = new FileInputStream(masterPath+shiftimage);
BufferedInputStream buf1 = new BufferedInputStream(in1);
Bitmap bMap1 = BitmapFactory.decodeStream(buf1);
ivBtnSym.setImageBitmap(bMap1);
in1.close();
buf1.close();
} catch (Exception e) { }
...
linLayBtnInside.addView(ivBtnSym);
现在我需要将ImageView的位图,例如masterPath+“/1.png”更改为masterPath+“/2.png”。。。你会怎么做
谢谢!:) 如果您确定图像名称是唯一的 您可以尝试使用标记:
final LinearLayout linLayRow1 = (LinearLayout) findViewById(R.id.LLrow1);
...
try {
FileInputStream in1 = new FileInputStream(masterPath+shiftimage);
BufferedInputStream buf1 = new BufferedInputStream(in1);
Bitmap bMap1 = BitmapFactory.decodeStream(buf1);
ivBtnSym.setImageBitmap(bMap1);
ivBtnSym.setTag(masterPath+shiftimage);
in1.close();
buf1.close();
} catch (Exception e) { }
...
linLayBtnInside.addView(ivBtnSym);
现在,当您要检索ImageView时:
ImageView retrieved = (ImageView) linLayBtnInside.findViewByTag(query);
您有一个包含ImageView的根视图吗?或者一组图像视图?我有一个带有IVs的linearlayout(最终linearlayout linLayRow1=(linearlayout)findViewById(R.id.LLrow1);)。