2017-12-20 41 views
0

材料ダイアログの値を入力する配列文字列リストがあります。ダイアログ内のアイテムをクリックすると、その位置にアイテムを取得し、その値をTextViewに設定します。残念ながら、私が選択した項目に関係なく、TextViewに最後の値を設定します。 材料ダイアログの位置にある項目の値を表示

は私のコード:

new MaterialDialog.Builder(DetailProfileActivity.this) 
    .title(R.string.id_types_title) 
    .items(set) 
    .itemsCallbackSingleChoice(0, new MaterialDialog.ListCallbackSingleChoice() { 
     @Override 
     public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { 
      idType = which; 
      switch (idType){ 
       case 0: 
        txtIdType.setText("Voters"); 
       case 1: 
        txtIdType.setText("Passport"); 
       case 2: 
        txtIdType.setText("DriversLicense"); 
      } 

      return true; 
     } 
    }) 
    .positiveText(R.string.choose) 
    .show(); 
+0

R2R @私の問題は、私は唯一のも、私のTextViewに設定した値「DriversLicense」を得ることであるあなたが使用できる文字列の結果を与えるこのonSelection()をお試しください私は別のオプションを選択した場合。 –

答えて

0

は直接

new MaterialDialog.Builder(DetailProfileActivity.this) 
      .title(R.string.id_types_title) 
      .items(set) 
      .itemsCallbackSingleChoice(0, new MaterialDialog.ListCallbackSingleChoice() { 
       @Override 
       public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { 
        txtIdType.setText(text); 
        return true; 
       } 
      }) 
      .positiveText(R.string.choose) 
      .show(); 
} 
+0

ありがとうございます。私は何を考えていたのか知​​りません。 –

関連する問題