【发布时间】:2013-10-18 12:38:59
【问题描述】:
我想在FrameLayout 中设置Activity。这是我的代码:
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(this).inflate(R.layout.wallpaper, null);将其更改为 View myview =inflater.inflate(R.layout.wallpaper, null);
-
谢谢你,我明白了我解决了这个错误现在我有另一个问题我想在这个框架布局中显示一个活动,活动名称是壁纸我如何在框架布局中显示这个活动
标签: java android nullpointerexception layout-inflater android-framelayout