View not found when replacing fragment
I have an Activity that uses fragments. on some actions I replace the visible fragment. This works very well, except that one user reports an error with their photon droid.
Here is the stack trace:
java.lang.IllegalArgumentException: No view found for id 0x7f060091 (com.b2.livewants:id/user_profile_fragment) for fragment UserProfileInfoFragment{40b3a8c0 #2 id=0x7f060091}
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:903)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:429)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3844)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
And here's this function:
private void setFragment(Fragment fr){
getFragmentManager()
.beginTransaction()
.replace(R.id.user_profile_fragment, fr)
.commit();
}
Edit:
Here is the (abbreviated) layout file:
<?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">
...
<FrameLayout
android:id="@+id/user_profile_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
How is this possible? Android seems to have problems to find a view in this case ... Has anyone had this problem before or has a hint for me?
Thanks Simon
+3
source to share
No one has answered this question yet
Check out similar questions: