'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.
Solution 1:[1]
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);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Dharman |