开发者

Android Layout Inflater

开发者 https://www.devze.com 2023-02-24 12:51 出处:网络
I am trying to get a id from different xml file and i am tring to use inflater for that but it doesn\'t work. I have searched a lot but it didn\'t help me about by code

I am trying to get a id from different xml file and i am tring to use inflater for that but it doesn't work. I have searched a lot but it didn't help me about by code

This is my code;

            final LayoutInflater factory = getLayoutInflater();
        final View textEntryView = factory.inflate(R.layout.tab1, null);
        Bitmap thumbnail = (Bitmap)data.getExtras().get("data");
        ImageView image = (ImageView)textEntryView.findViewById(R.id.imageView1);
        image.setImageBitmap(thumbnail);

in this code I am getting the last photo which I took from sd card and I want to post t开发者_运维技巧his photo to the image view in a different xml. My code doesn't throw exeption but it does not post the image to the image view

Thanks


The code you posted here will inflate the XML to a View, look for an image View in that View with the id of R.id.imageView1, then set the image bitmap.

If this is all you do, this inflated view (textEntryView) will never be seen as it has not been added as a child to another view, nor is it added as content for an activity context.

0

精彩评论

暂无评论...
验证码 换一张
取 消