2017-02-14 40 views
0

登錄活動Android開放片段從活性沒有視圖找到ID 0x7f0(com.pakagename:ID/flLoginMainLayout),用於片段OpenFragmentName {AnotherFragment}

fragmentTransaction.add(R.id.flLoginMainLayout, 
OpenFragmentName, AppConstants.tag_prev_list_fragment); 

它給我錯誤以下錯誤

E/UncaughtException:java.lang.IllegalArgumentException異常:(:ID/flLoginMainLayout com.doctorstay),用於片段OpenFragmentName {4450afc0#1的id = 0x7f0f0113 AnotherFragment}

我還用Diff容器調用相同的代碼在AnotherFragment未發現ID 0x7f0f0113視圖ID

((AnotherFragment) fragment).addFragment(R.id.flMainLayout, 
           OpenFragmentName, AppConstants.tag_prev_list_fragment); 

XML佈局:activity_login_fragment(用途是flLoginMainLayout)

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/flLoginMainLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.pakagename.pakagename2.OpenFragmentName"> 

</FrameLayout> 

XML對於登錄佈局:activity_login(用途是flLoginMainLayout)

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/flRootLogin" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.pakagename.LoginActivity"> 
+0

請發佈您的佈局代碼 –

回答

0

問題的觀點,美有用膨脹片段

確保視圖是正確的佈局

  • 此異常也可能發生如果正在膨脹等 佈局存在哪些要傳遞給 FragmentTransaction.replace(INT ID,片段)佈局ID指定。確保佈局ID是唯一的 它應該工作。