I have an App with one main activity, and this activity has 5 actionTabs
, each actionTab
contains a fragment
, so I have 5 fragments
as well.
The first fragment
just displaying the word "hello".
In the second fragment
, It just displays some textviews
to indicate which callback of the activity's lifecycle is being called.
The third fragment
, in its layout, it contains a tablelayout
with 3 rows, each row has a image
, textview
and an edittext
. And when access this fragment
contained in thistab
and when I rotate the device, the App does not crash.
The App crashes only when I access the fourth or the fifth tab
and rotate the device which contains the following:
the fourth and the fifth tab
have three LinearLayout
and three relative layout
respectively. The main linearlayout
of the fourth fragment
is oriented vertically, and the three nested linearlayouts
are oriented horizontally, and each one of them contain imageview
, textview
and edittext
.
The fifth fragemnt
is almost the same as the fourth one, but instead of the linearlayouts
, it has relativlayout
.
To Note:
the second fragment
has the method onSavedInstance
, and when the App crashed when accessing the fourth or the fifth fragment
, the logcat
complains about the onSavedInstance
and produce the below posted messages.
I want to know why the App crashes when I access either the fourth fragment
or the fifth and rotate the device?
LogCat:
11-02 20:48:29.699: E/AndroidRuntime(22282): FATAL EXCEPTION: main
11-02 20:48:29.699: E/AndroidRuntime(22282): Process: com.example.viewpagerwithactiontabstest00, PID: 22282 11-02 20:48:29.699: E/AndroidRuntime(22282): java.lang.NullPointerException 11-02 20:48:29.699: E/AndroidRuntime(22282): at com.example.viewpagerwithactiontabstest00.Aufgabe_2.onSaveInstanceState(Aufgabe_2.java:142) 11-02 20:48:29.699: E/AndroidRuntime(22282): at android.support.v4.app.Fragment.performSaveInstanceState(Fragment.java:1647) 11-02 20:48:29.699: E/AndroidRuntime(22282): at android.support.v4.app.FragmentManagerImpl.saveFragmentBasicState(FragmentManager.java:1610)
onSavedInstance() methos:
@Override
public void onSaveInstanceState(Bundle outState) {
// TODO Auto-generated method stub
super.onSaveInstanceState(outState);
outState.putString("TEXT", tv_00.getText().toString());
}
0 comments:
Post a Comment