ボタンを押すと、リストを含むダイアログ ボックスが表示され、リスト内の特定の項目を選択すると、番号ピッカー ダイアログが表示されるアプリケーションがあります。私がしたいことは、ユーザーが番号ピッカー ダイアログから番号を選択した後、番号ピッカー ダイアログのみが閉じ、ダイアログ ボックスはそのままにすることです。
これはこれまでの私のコードです。
これは、最初のダイアログ ボックス (リストのあるもの) のコードです。
private void generateUnitDialog(String[] productUnit) {
final CharSequence[] items = productUnit;
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Make your selection");
builder.setPositiveButton("Confirm", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// Handle Confirm action here
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// Handle cancel action here
}
});
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
// Do something with the selection
Toast.makeText(getApplicationContext(),
"Item Click detected", Toast.LENGTH_SHORT)
.show();
generateQuantityDialog();
}
});
builder.setCancelable(false);
AlertDialog alert = builder.create();
alert.show();
}
特定のリスト項目が選択されると、次のコードを使用して numberpicker ダイアログがポップアップします。
public int generateQuantityDialog(){
final Dialog d = new Dialog(com.angelo.orderform.OrderForm.this);
d.setTitle("Choose Quantity");
d.setContentView(R.layout.dialog);
Button b1 = (Button) d.findViewById(R.id.button1);
Button b2 = (Button) d.findViewById(R.id.button2);
final NumberPicker np = (NumberPicker) d.findViewById(R.id.numberPicker1);
np.setMaxValue(100000);
np.setMinValue(1);
np.setWrapSelectorWheel(true);
//np.setOnValueChangedListener(this);
b1.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
//tv.setText(String.valueOf(np.getValue()));
d.dismiss();
}
});
b2.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
d.dismiss();
}
});
d.show();
return(np.getValue());
}
ユーザーが特定の番号を選択すると、番号ピッカー ダイアログとリストが閉じます。リストのダイアログを表示したままにしたい。
どうやら、 setCancellable(false) は役に立ちません。
何か案は?別のアプローチであっても、私は耳を傾けています。