如何从FrameLayout获取对XML文件的引用 [英] How to get a reference to an XML file from FrameLayout

查看:180
本文介绍了如何从FrameLayout获取对XML文件的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要引用单独的XML文件(即FrameLayout),但我不知道该怎么做,此代码不起作用:

I need to get reference to separate XML file which is FrameLayout but I can't figure out how to do it, this code doesn't work:

FrameLayout desktopFrameLayout = (FrameLayout) findViewById(R.id.desktopsFramelayout);
desktopFrameLayout.setDrawingCacheEnabled(true);
desktopFrameLayout.buildDrawingCache();
Bitmap bitmap = desktopFrameLayout.getDrawingCache();

推荐答案

为此,您必须使用充气视图.

For that you have to use inflate view.

LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
View view = inflater.inflate(R.layout.mylayout, null);

FrameLayout item = (FrameLayout ) view.findViewById(R.id.desktopsFramelayout);

这篇关于如何从FrameLayout获取对XML文件的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆