My Requirement is like whenever user select any number from number picker on that time that number should be printed on some text view and second time whenever user opens dialog again than previously selected number should be shown on that dialog
...
...
view = (TextView) findViewById(R.id.textView7);
LinearLayout L = (LinearLayout) findViewById(R.id.linearLayout5);
L.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
showdialog();
}
});
}
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
Log.i("value is",""+newVal);
}
public void showdialog()
{
Dialog dialog = new Dialog(NameActivity.this);
View npView = getLayoutInflater().inflate(R.layout.multidialog, null);
final NumberPicker firPicker =
(NumberPicker) npView.findViewById(R.id.numberPicker1);
firPicker.setMaxValue(9);
firPicker.setMinValue(0);
final NumberPicker secPicker =
(NumberPicker) npView.findViewById(R.id.numberPicker2);
secPicker.setMaxValue(9);
secPicker.setMinValue(0);
final NumberPicker tirPicker =
(NumberPicker) npView.findViewById(R.id.numberPicker3);
tirPicker.setMaxValue(9);
tirPicker.setMinValue(0);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("title");
builder.setView(npView);
builder.setPositiveButton("Set",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
view.setText(String.valueOf(firPicker.getValue() *100
+ secPicker.getValue() *10 + tirPicker.getValue()));
}
});
builder.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
});
dialog = builder.create();
dialog.show();
}