2013-03-05 9 views
6

muszę się odniesienie do oddzielnego pliku XML jest wich FrameLayout ale nie mogę dowiedzieć się, jak to zrobić, ten kod nie działa:android dostać się do układu odniesienia w kodzie

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

wykorzystania powinno maszyn LayoutInflater inflater = (LayoutInflater) context.getSystemService (Context.LAYOUT_INFLATER_SERVICE); –

Odpowiedz

15

Do tego musisz użyć zawyżonego widoku.

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

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

Tylko dla rekordu można uzyskać tylko usługę systemową w lub po wywołaniu Activity 'onCreate()'. –

Powiązane problemy