我在 src > myproject.test > HomeView 中有一个自定义视图
在我的主要布局 xml 中,我有以下内容:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/home_root"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<myproject.test.HomeView
android:id="@+id/home_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
</myproject.test.HomeView>
</LinearLayout>
在 HomeActivity 中,我在 onCreate 方法中有这样的调用。
setContentView(R.layout.main);
HomeView mHomeView = (HomeView) this.findViewById(R.id.home_view);
调用 setContentView 方法时应用强制关闭。看来我的主要 xml 不正确。
有任何想法吗?