我需要引用单独的 XML 文件,即 FrameLayout,但我不知道该怎么做,这段代码不起作用:
FrameLayout desktopFrameLayout = (FrameLayout) findViewById(R.id.desktopsFramelayout);
desktopFrameLayout.setDrawingCacheEnabled(true);
desktopFrameLayout.buildDrawingCache();
Bitmap bitmap = desktopFrameLayout.getDrawingCache();
最佳答案
为此你必须使用膨胀 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);
关于android - 如何从 FrameLayout 获取对 XML 文件的引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15221967/