【发布时间】:2013-07-02 07:47:29
【问题描述】:
我在扩展 LinearLayout 的自定义视图类的构造函数中的 super(context) 行上有一个 NullPointerException。使用android 4.1.2虚拟设备测试没有出现问题。
public class customView extends LinearLayout {
private NavigationBar navigationBar;
private Activity activity;
public customView(Context context) {
super(context);
activity = (Activity) context;
navigationBar = new NavigationBar(context);
LayoutParams Params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
setLayoutParams(Params);
setOrientation(LinearLayout.VERTICAL);
this.addView(navigationBar);
}
【问题讨论】:
标签: android android-linearlayout superclass android-2.3-gingerbread