9

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();
Jason Aller
  • 3,475
  • 28
  • 40
  • 37
Mickey Tin
  • 3,225
  • 8
  • 39
  • 69
  • Use should have to used LayoutInflater inflater = (LayoutInflater)context.getSystemService (Context.LAYOUT_INFLATER_SERVICE); – Bhavdip Sagar Mar 05 '13 at 10:57

1 Answers1

17

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);
Chirag
  • 56,384
  • 29
  • 154
  • 197