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,541
  • 28
  • 38
  • 38
Mickey Tin
  • 3,408
  • 10
  • 42
  • 71
  • 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,621
  • 29
  • 151
  • 198