I'm not using a ListActivity because I want to extend FragmentActivity. Instead I'm trying to use:
ListView lv = (ListView) findViewById(R.id.mainListView);
Unfortunately lv is null.
In my xml I have:
<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
</ListView>
I've also tried using different android id's for the list view such as the one you have to use when you use ListActivity, but it's always Null.
Edit: I was trying to call findViewById before calling setContentView. Calling setContentView first fixed it.
As JRaymond mentioned in a comment awhile ago, I needed to call setContentView before using findViewById.
You should put setContentView on top of findViewById.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With