2015-11-01 26 views
0

舉杯我有一個問題,我DialogFragment巢AlertDialog或內部DialogFragment

public class HorairesFragment extends DialogFragment { 

    @Override 
    public Dialog onCreateDialog(Bundle savedInstanceState) { 
     LayoutInflater i = getActivity().getLayoutInflater(); 
     mView = i.inflate(R.layout.intervention_horaires_fragment, null); 
     AlertDialog.Builder b= new AlertDialog.Builder(getActivity()) 
       .setPositiveButton(R.string.ok, 
         new DialogInterface.OnClickListener() { 
          public void onClick(DialogInterface dialog, int whichButton) { 

          AlertDialog alert = new AlertDialog.Builder(getFragmentManager()) 
          .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { 
           public void onClick(DialogInterface dialog, int id) { 
            dialog.cancel(); 
           } 
          }).create(); 
          alert.setMessage(message); 
          alert.setCancelable(false); 
          alert.show(); 

          } 
         } 
       ) 
       .setNegativeButton(R.string.annuler, 
         new DialogInterface.OnClickListener() { 
          public void onClick(DialogInterface dialog, int whichButton) { 
           dialog.dismiss(); 
          } 
         } 
       ); 
     b.setView(mView); 
     return b.create(); 
    } 
} 

我刪除了可讀性的代碼。下面是

enter image description here

有時用戶輸入一些不正確的數據,所以當我點擊確定按鈕,我需要出示帶有自定義錯誤消息的AlertDialog(或吐司也許)我DialogFragment截圖。

的問題如下:當他點擊OK OK在AlertDialog,它也解僱我的對話框

enter image description here

是否可以糾正的行爲呢?

+0

如何在錯誤對話框之後再次顯示對話框? –

+0

警報對話框上的按鈕總是關閉警報對話框,這不是第二個對話框的問題。 – njzk2

+0

+ njzk2你是對的。如果我刪除第一個DialogFragment上的正面按鈕並將其轉換爲一個按鈕。問題已經解決了。我正在尋找像材料對話框中的兩個按鈕樣式.. –

回答

相關問題