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 cl开发者_JAVA技巧ass 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.
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);
精彩评论