findViewById() may produce NullPointerException

后端 未结 3 1953
灰色年华
灰色年华 2021-01-12 03:42

I have many of these calls:

(ListView) getView().findViewById(R.id.main_list_view);
(TextView) getView().findViewById(R.id.items_no);
....

3条回答
  •  执念已碎
    2021-01-12 04:38

    This is a known issue in android.support.v7.app.AppCompatActivity and it has been fixed in v24.

    https://code.google.com/p/android/issues/detail?id=203345

    You won't have any issues with android.support.v4.app.FragmentActivity or android.app.Activity

提交回复
热议问题