小编use*_*368的帖子

如何进行号码选择器对话?

我的要求就像每当用户从数字选择器中选择任何数字时,该数字应该打印在某个文本视图上,第二次,当用户再次打开对话框时,应该在该对话框上显示先前选择的数字

    ...
    ...

    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 …
Run Code Online (Sandbox Code Playgroud)

android android-dialog

6
推荐指数
1
解决办法
2043
查看次数

标签 统计

android ×1

android-dialog ×1