igde_
igde_

Reputation: 261

Update an image to a view using Layoutinflater

ImageView image= 
(ImageView)getLayoutInflater().inflate(R.layout.tab1,null).findViewById(R.id.imageView1);

Bitmap thumbnail = (Bitmap)data.getExtras().get("data");

 image.setImageBitmap(thumbnail);

What is the problem with this inflater? I have two tabs and this Java class setContentView to tab2.xml but I want to post my image to tab1.xml. I have created an imageview which has an id of imageView1 and I want to post this image over there.

Upvotes: 1

Views: 1294

Answers (1)

petrnohejl
petrnohejl

Reputation: 7759

Try to use this code:

View v = LayoutInflater.from(context).inflate(R.layout.some_view, null);        
ImageView iv = (ImageView)v.findViewById(R.id.some_view_image);
iv.setImageResource(R.drawable.icon);

Upvotes: 2

Related Questions