我想在FrameLayout
中設置Activity
。這裏是我的代碼:android中的layoutinflater nullpointerexception
FrameLayout fl = new FrameLayout(this);
fl = (FrameLayout) findViewById(R.id.actioncontent);
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View myview =LayoutInflater.from(this).inflate(R.layout.wallpaper, null);
fl.removeAllViews();
fl.addView(myview);
我得到一個錯誤NullPointerException異常。
視圖MyView的= LayoutInflater.from(本).inflate(R.layout.wallpaper,NULL);將其更改爲查看myview = inflater.inflate(R.layout.wallpaper,null); –
謝謝你,我知道了我解決了這個錯誤現在我有另一個問題,我想在這個框架佈局和活動名稱顯示一個活動是壁紙我如何顯示此框架佈局 –