I create an imageView here in my coding in my gridView adapter class:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// Try to reuse the views
ImageView view = (ImageView) convertView;
boolean checked = (mCheckBox==null)?false:(((CheckBox) mCheckBox).isChecked());
// if convert view is null then create a new instance else reuse it
if (view == null) {
view = new ImageView(Context);
Log.d("GridViewAdapter", "new imageView added");
}
Is there a way that I can assign view
an id so that I can use that id in another class to set an image?
I am going about setting the image like this:
/// Let's save to a .jpg file ...
File file = new File(mContext.getFilesDir().getAbsolutePath() + "/test2.jpg");
FileOutputStream out;
try {
file.createNewFile();
out = new FileOutputStream(file);
appBmp.compress(Bitmap.CompressFormat.JPEG, 80, out);
out.close();
// Load back the image file to confirms it works
Bitmap bitmap = BitmapFactory.decodeFile( file.getAbsolutePath() );
ImageView imageView1 = (ImageView)v.findViewById(R.id.layout1);
imageView1.setImageBitmap( bitmap );
}
So that way I could just set that id in the findViewById
and it would set the image to that imageView.
I have already tried setting up an ids.xml file with different id values and then assigning it to the imageView by doing this:
view.setId(R.id.layout1);
but this didn't work.