0

我正在使用alertDialog v7創建我的自定義對話框。 在我的自定義視圖內我有editType「phone | numberPassword」的editText。 但是當我嘗試輸入一些文字這種情況下 - 這是不工作,意味着EDITTEXT不顯示任何改變,任何新的符號......EditText在AlertDialog v7中不起作用

這裏是我的alertDialog自定義視圖:

<LinearLayout 
    android:id="@+id/ll_login_regLayout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:visibility="visible" 
    android:paddingRight="@dimen/dialog_padding" 
    android:paddingLeft="@dimen/dialog_padding" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto"> 
    <EditText 
      android:id="@+id/et_p1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:inputType="phone|numberPassword" 
      /> 
</LinearLayout> 

我這裏是我的代碼片段裏面:

private void showSetPassDialog(){ 
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 
    View dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_register_pass, null); 

    builder.setView(dialogView); 
    builder.setPositiveButton(getString(R.string.text_dialogpsw_btn_ok_password), 
      new DialogInterface.OnClickListener() { 
       @Override 
       public void onClick(DialogInterface dialog, int which) { 
        if (!chb.isChecked()) { 
         String mess = getString(R.string.error_check_dogovor); 
         SU_Tools.showToast(getActivity(), mess); 
         showSetPassDialog(); 
        } else { 
         mMainLayout.setVisibility(View.VISIBLE); 
        } 
       } 
      }); 
    builder.show(); 
} 
+1

*我嘗試鍵入一些文本 - 這是行不通的... *是什麼意思? – Blackbelt

+0

editText不顯示任何更改 –

回答

0

您需要打破你如何設置對話框。試試這個:

AlertDialog alert = new AlertDialog.Builder(this) 
    .setView(dialogView) 
    .setPositiveButton(getString(R.string.text_dialogpsw_btn_ok_password), null) 
    .create(); 

alert.setOnShowListener(new DialogInterface.OnShowListener() { 
    @Override 
    public void onSow(DialogInterface dialogInterface) { 
     final Button button = alert.getButton(AlertDialog.BUTTON_POSITIVE); 
     button.setOnClickListener(your code here); 
    } 
}); 

alert.show();