I have 2 activities. The 2nd .xml looks like:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ListView
android:id="@+id/TrainsListView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
Part of manifest:
<activity android:name="TrainsActivity">
</activity>
And I'm trying to get TrainsListView:
mListView = (ListView) findViewById(R.id.TrainsListView);
But after this mlistView is null. Why?
I'm guessing this is happening in your Activity's onCreate() method because you are calling findViewById() before you have called setContentView(). If that's not the case then please show more of your code.
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