だから私はタブ付きのアプリケーションを作ろうとしています...しかし、ヌルポインタ例外でクラッシュし続けます。null ポインターの原因となっている可能性のあるすべての変数を調べたところ、絞り込んだと思います。
ListView activeList = (ListView) findViewById(R.id.activelist);
if(activeList == null) {
Log.e("com.name.app", "activeList null");
}
これは null を返します。それはすべきですか?フラグメントを使用して、タブ付きレイアウトを構築しようとしています。これは参照しているxmlです。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<ListView
android:id="@+id/activelist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:persistent="true" >
</ListView>
</LinearLayout>
助けてくれてありがとう!
編集:
super.onCreate(savedInstanceState);
setContentView(R.layout.tabs_layout);
それが私のコンテンツビューのようです。
編集:これは私の最終的なコードがどのように見えるかです!
LayoutInflater inflater = (LayoutInflater) getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout mContainer = (LinearLayout) inflater.inflate(R.layout.tab_frag1_layout, null);
ListView activeList = (ListView) mContainer.findViewById(R.id.activelist);