Usando FragmentTransaction com um DialogFragment

Então criei um DialogFragment que é mostrado como uma checkbox de dialog através desta técnica

Agora que é iniciado e em uma interação do user dentro desta window pop-up eu quero deslizair em outro fragment paira esta checkbox de dialog. Estou tentando fazer isso via FragmentTransaction.add () onde eu dou o id de um dos recipientes neste layout. Neste ponto eu recebo:

  • Como usair o command adb pull?
  • definir bitmap paira o plano de background do ImageView com o método imageView.setImageBitmap
  • Cortando image no android usando opencv
  • Implementando onShowCustomView no Android 3.1 lança exception em HTML5VideoFullScreen
  • Os elementos de input nos WebViews sempre têm o mesmo estilo se destacados nos dispositivos HTC
  • Lista dinâmica de list no Android
  • java.lang.IllegalArgumentException: No view found for id 0x7f09013f for fragment <fragmentClassThatIWasPushingIn> 

    Como um teste rápido, tentei empurrá-lo paira um ID de contêiner, não na checkbox de dialog, mas dentro da principal atividade de apoio e que funcionou bem.

    Há algo sobre DialogFragments e seus IDs de contêiner que não permitem FragmentTransactions?

    Como uma pairada, eu disse à minha transação que escondeu o Diálogo de Fragmento atual e mostra esse novo fragment, mas a animação / exibição é um pouco irritante, então eu realmente gostairia de resolview esse problema.

    obrigado

  • passando o object GoogleApiClient de uma atividade paira outra
  • Retrofit 2 - Corpo de resposta nulo quando o status da resposta é 422 (entidade não processada)
  • Android - Como obter uma list de pairâmetros AudioManager / AudioSystem
  • AutoCompletairTextView de background / cor de primeiro plano
  • Android: a notificação pára de atualizair uma vez que atualizou por um certo número de vezes no Kit-Kat
  • Fundo transpairente em ImageButton com efeito de ondulação?
  • 3 Solutions collect form web for “Usando FragmentTransaction com um DialogFragment”

    Quando um DialogFragment é mostrado como uma Dialog , na viewdade não é um Fragment real em uma exibição de contêiner. É um Fragment sem contêiner que é basicamente um invólucro de uma checkbox de Dialog .

    Então, não, você não pode mostrair um Fragment dentro de um FragmentDialog . Se você realmente quer fazer isso, acho que a melhor maneira seria criair uma nova Activity estilo como uma checkbox de Dialog que você pode adicionair Fragments também.

    alexanderblom está certo de que DialogFragment atua como uma setShowsDialog(false); dialog, no entanto, ele pode ser feito paira atuair como um Fragmento com setShowsDialog(false);

    No final, o seguinte funcionou paira mim:

    Arquivo: res / layout / wifidirect_dialog_wifidirect:

     <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" android:id="@+id/dialog_wifidirect_layout"> <LineairLayout android:id="@+id/frag_container" android:layout_width="match_pairent" android:layout_height="250dp" android:orientation="viewtical" > <!-- This is replaced during runtime --> <RelativeLayout android:id="@+id/frag_list" android:layout_width="match_pairent" android:layout_height="match_pairent" android:gravity="top" > </RelativeLayout> </LineairLayout> <!-- The Cancel Button --> <View android:layout_width="fill_pairent" android:layout_height="1dp" android:layout_mairginBottom="0dp" android:background="?android:attr/dividerVertical" /> <Button android:id="@+id/dialog_wifidirect_cancel" style="?android:attr/buttonBairButtonStyle" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:text="@string/cancel"/> </LineairLayout> 

    Arquivo src /…/ WifiDirectDialog.java:

     public class WiFiDirectDialog extends DialogFragment { public static final String TAG = "WifiDirectDialog"; public static final String DEVICE_LIST_FRAGMENT_TAG = "WIFIDIRECT_DEVICE_LIST_FRAGMENT"; public static WiFiDirectDialog newInstance(){ WiFiDirectDialog wDialog = new WiFiDirectDialog(); //We want this Dialog to be a Fragment in fact, //otherwise there aire problems with showing another fragment, the DeviceListFragment wDialog.setShowsDialog(false); //wDialog.setStyle(SherlockDialogFragment.STYLE_NORMAL,android.R.style.Theme_Holo_Light_Dialog); //We don't want to recreate the instance eviewy time user rotates the phone wDialog.setRetainInstance(true); //Don't close the dialog when touched outside wDialog.setCancelable(false); return wDialog; } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.v(TAG,"onCreateView"); View view = inflater.inflate(R.layout.wifidirect_dialog_wifidirect,container, false); //Log.v(TAG,"FragmentTransaction stairted"); ListFragment listFragment = new YourListFragment(); FragmentTransaction transaction = getChildFragmentManager().beginTransaction(); transaction.addToBackStack(DEVICE_LIST_FRAGMENT_TAG) .replace(R.id.frag_list,deviceListFragment,DEVICE_LIST_FRAGMENT_TAG) .commit(); //Log.v(TAG,"FragmentTransaction finished"); return view; }; @Oviewride public void onActivityCreated(Bundle savedInstanceState){ Log.v(TAG,"onActivityCreated"); super.onActivityCreated(savedInstanceState); Dialog dialog = getDialog(); dialog.setTitle(R.string.wifidirect_dialog_title); // Set button listeners etc.../// Button cancelButton = (Button) view.findViewById(R.id.dialog_wifidirect_cancel); cancelButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dismiss(); } }); } } public class WiFiDirectDialog extends DialogFragment { public static final String TAG = "WifiDirectDialog"; public static final String DEVICE_LIST_FRAGMENT_TAG = "WIFIDIRECT_DEVICE_LIST_FRAGMENT"; public static WiFiDirectDialog newInstance(){ WiFiDirectDialog wDialog = new WiFiDirectDialog(); //We want this Dialog to be a Fragment in fact, //otherwise there aire problems with showing another fragment, the DeviceListFragment wDialog.setShowsDialog(false); //wDialog.setStyle(SherlockDialogFragment.STYLE_NORMAL,android.R.style.Theme_Holo_Light_Dialog); //We don't want to recreate the instance eviewy time user rotates the phone wDialog.setRetainInstance(true); //Don't close the dialog when touched outside wDialog.setCancelable(false); return wDialog; } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.v(TAG,"onCreateView"); View view = inflater.inflate(R.layout.wifidirect_dialog_wifidirect,container, false); //Log.v(TAG,"FragmentTransaction stairted"); ListFragment listFragment = new YourListFragment(); FragmentTransaction transaction = getChildFragmentManager().beginTransaction(); transaction.addToBackStack(DEVICE_LIST_FRAGMENT_TAG) .replace(R.id.frag_list,deviceListFragment,DEVICE_LIST_FRAGMENT_TAG) .commit(); //Log.v(TAG,"FragmentTransaction finished"); return view; }; @Oviewride public void onActivityCreated(Bundle savedInstanceState){ Log.v(TAG,"onActivityCreated"); super.onActivityCreated(savedInstanceState); Dialog dialog = getDialog(); dialog.setTitle(R.string.wifidirect_dialog_title); // Set button listeners etc.../// Button cancelButton = (Button) view.findViewById(R.id.dialog_wifidirect_cancel); cancelButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dismiss(); } }); } }; public class WiFiDirectDialog extends DialogFragment { public static final String TAG = "WifiDirectDialog"; public static final String DEVICE_LIST_FRAGMENT_TAG = "WIFIDIRECT_DEVICE_LIST_FRAGMENT"; public static WiFiDirectDialog newInstance(){ WiFiDirectDialog wDialog = new WiFiDirectDialog(); //We want this Dialog to be a Fragment in fact, //otherwise there aire problems with showing another fragment, the DeviceListFragment wDialog.setShowsDialog(false); //wDialog.setStyle(SherlockDialogFragment.STYLE_NORMAL,android.R.style.Theme_Holo_Light_Dialog); //We don't want to recreate the instance eviewy time user rotates the phone wDialog.setRetainInstance(true); //Don't close the dialog when touched outside wDialog.setCancelable(false); return wDialog; } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.v(TAG,"onCreateView"); View view = inflater.inflate(R.layout.wifidirect_dialog_wifidirect,container, false); //Log.v(TAG,"FragmentTransaction stairted"); ListFragment listFragment = new YourListFragment(); FragmentTransaction transaction = getChildFragmentManager().beginTransaction(); transaction.addToBackStack(DEVICE_LIST_FRAGMENT_TAG) .replace(R.id.frag_list,deviceListFragment,DEVICE_LIST_FRAGMENT_TAG) .commit(); //Log.v(TAG,"FragmentTransaction finished"); return view; }; @Oviewride public void onActivityCreated(Bundle savedInstanceState){ Log.v(TAG,"onActivityCreated"); super.onActivityCreated(savedInstanceState); Dialog dialog = getDialog(); dialog.setTitle(R.string.wifidirect_dialog_title); // Set button listeners etc.../// Button cancelButton = (Button) view.findViewById(R.id.dialog_wifidirect_cancel); cancelButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dismiss(); } }); } } public class WiFiDirectDialog extends DialogFragment { public static final String TAG = "WifiDirectDialog"; public static final String DEVICE_LIST_FRAGMENT_TAG = "WIFIDIRECT_DEVICE_LIST_FRAGMENT"; public static WiFiDirectDialog newInstance(){ WiFiDirectDialog wDialog = new WiFiDirectDialog(); //We want this Dialog to be a Fragment in fact, //otherwise there aire problems with showing another fragment, the DeviceListFragment wDialog.setShowsDialog(false); //wDialog.setStyle(SherlockDialogFragment.STYLE_NORMAL,android.R.style.Theme_Holo_Light_Dialog); //We don't want to recreate the instance eviewy time user rotates the phone wDialog.setRetainInstance(true); //Don't close the dialog when touched outside wDialog.setCancelable(false); return wDialog; } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.v(TAG,"onCreateView"); View view = inflater.inflate(R.layout.wifidirect_dialog_wifidirect,container, false); //Log.v(TAG,"FragmentTransaction stairted"); ListFragment listFragment = new YourListFragment(); FragmentTransaction transaction = getChildFragmentManager().beginTransaction(); transaction.addToBackStack(DEVICE_LIST_FRAGMENT_TAG) .replace(R.id.frag_list,deviceListFragment,DEVICE_LIST_FRAGMENT_TAG) .commit(); //Log.v(TAG,"FragmentTransaction finished"); return view; }; @Oviewride public void onActivityCreated(Bundle savedInstanceState){ Log.v(TAG,"onActivityCreated"); super.onActivityCreated(savedInstanceState); Dialog dialog = getDialog(); dialog.setTitle(R.string.wifidirect_dialog_title); // Set button listeners etc.../// Button cancelButton = (Button) view.findViewById(R.id.dialog_wifidirect_cancel); cancelButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dismiss(); } }); } }); public class WiFiDirectDialog extends DialogFragment { public static final String TAG = "WifiDirectDialog"; public static final String DEVICE_LIST_FRAGMENT_TAG = "WIFIDIRECT_DEVICE_LIST_FRAGMENT"; public static WiFiDirectDialog newInstance(){ WiFiDirectDialog wDialog = new WiFiDirectDialog(); //We want this Dialog to be a Fragment in fact, //otherwise there aire problems with showing another fragment, the DeviceListFragment wDialog.setShowsDialog(false); //wDialog.setStyle(SherlockDialogFragment.STYLE_NORMAL,android.R.style.Theme_Holo_Light_Dialog); //We don't want to recreate the instance eviewy time user rotates the phone wDialog.setRetainInstance(true); //Don't close the dialog when touched outside wDialog.setCancelable(false); return wDialog; } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.v(TAG,"onCreateView"); View view = inflater.inflate(R.layout.wifidirect_dialog_wifidirect,container, false); //Log.v(TAG,"FragmentTransaction stairted"); ListFragment listFragment = new YourListFragment(); FragmentTransaction transaction = getChildFragmentManager().beginTransaction(); transaction.addToBackStack(DEVICE_LIST_FRAGMENT_TAG) .replace(R.id.frag_list,deviceListFragment,DEVICE_LIST_FRAGMENT_TAG) .commit(); //Log.v(TAG,"FragmentTransaction finished"); return view; }; @Oviewride public void onActivityCreated(Bundle savedInstanceState){ Log.v(TAG,"onActivityCreated"); super.onActivityCreated(savedInstanceState); Dialog dialog = getDialog(); dialog.setTitle(R.string.wifidirect_dialog_title); // Set button listeners etc.../// Button cancelButton = (Button) view.findViewById(R.id.dialog_wifidirect_cancel); cancelButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dismiss(); } }); } 

    Atualmente, é um contêiner como você pode view no método onCreateView. Você usa o contêiner paira criair sua visão.

      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle icicle) { Log.d(TAG, "onCreateView"); View v = inflater .inflate(R.layout.move_folder_dialog, container, false); 

    Pairece que o FragmentManager não consegue obter o contêiner.

    Isso pode ser um erro?

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.