2014-11-03 3 views
0

단편에 문제가 있습니다. Fragment 안에 Dialog가 있고이 Dialog 안에 Fragment가 있습니다. 그러나 두 번째 조각을 추가 할 때 IllegalArgumentException : No view found for id ***** (fr.*****:id/container_list_collections) for fragment FragmentCollectionVignette이 있습니다.IllegalArgumentException 대화 상자의 단편

FragmentHP.java

public class FragmentHP extends Fragment { 

/** Bouton Ajouter à **/ 
private Button btAddTo; 

@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) { 
    View vueFragmentHP = inflater.inflate(R.layout.fragment_hp, container, false); 

    getFragmentManager().beginTransaction().replace(R.id.container_dernier_ajout, new FragmentDerniersAjoutsHP()).commit(); 
    getFragmentManager().beginTransaction().replace(R.id.container_collections, new FragmentCollectionsHP()).commit(); 
    getFragmentManager().beginTransaction().replace(R.id.container_ebooks, new FragmentEbooksHP()).commit(); 
    getFragmentManager().beginTransaction().replace(R.id.container_games, new FragmentGamesHP()).commit(); 
    getFragmentManager().beginTransaction().replace(R.id.container_software, new FragmentSoftwareHP()).commit(); 
    getFragmentManager().beginTransaction().replace(R.id.container_digital_creation, new FragmentDigitalCreationHP()).commit(); 

    btAddTo = (Button) vueFragmentHP.findViewById(R.id.bt_collections); 

    btAddTo.setOnClickListener(new OnClickListener() { 

     @Override 
     public void onClick(View v) { 
      LayoutInflater inflater = getActivity().getLayoutInflater(); 
      View view = inflater.inflate(R.layout.dialog_add_to, null); 
      final Dialog dialog = new Dialog(getActivity()); 

      dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
      dialog.setContentView(view); 
      dialog.show(); 
      dialog.setCanceledOnTouchOutside(false); 

      Button btValider = (Button) view.findViewById(R.id.bt_add_to); 

      getFragmentManager().beginTransaction().add(R.id.container_list_collections, new FragmentCollectionVignette()).commit(); 
     } 
    }); 

    return vueFragmentHP; 
} 

}

dialog_add_to.xml

<?xml version="1.0" encoding="UTF-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 
    <TextView 
     android:id="@+id/tv_add_to" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/add_to"/> 
    <TextView 
     android:id="@+id/tv_choose_collection" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/choose_collection" 
     android:layout_below="@id/tv_add_to"/> 

    <FrameLayout 
     android:id="@+id/container_list_collections" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/tv_choose_collection"/> 
    <Button 
     android:id="@+id/bt_add_to" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/valider" 
     android:layout_below="@id/container_list_collections"/> 
</RelativeLayout> 

문제가 무엇입니까? (죄송합니다 내 영어 아주 나쁜)

+0

프로젝트를 지우려고 했습니까? 때때로 자원을 변경해도 R 파일이 재생성되지 않습니다. – Marius

+0

네,하지만 같은 오류가 있습니다. – MichelRobico

답변

0

내가 문제가이 라인 getFragmentManager()에 생각 들어 BeginTransaction()을 (R.id.container_list_collections, 새로운 FragmentCollectionVignette을())를 추가 (커밋)...; 이 변경을 this.getActivity(). getFragmentManager(). beginTransaction(). add (R.

+0

동일한 오류가 있습니다 ... – MichelRobico

+0

대화 상자의 버튼 클릭시 다른 조각을 렌더링하려고합니다. –

+0

대화 상자에 단편을 삽입하고 싶습니다. – MichelRobico