NumberPickerを開いたときに特定の値を表示できますか?たとえば、私は最小値= 10、最大値= 50;NumberPickerで特定の値を表示
final NumberPicker picker = new NumberPicker(MonitorActivity.this);
picker.setMinValue(10);
picker.setMaxValue(50);
NumberPickerが開かれたとき、私は値を表示したい= 30の代わりに、スタンダール10 私はこれをどのように行うことができますか?
UPDATE:
upTv = (TextView) findViewById(R.id.upper_tv);
upTv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
show(180, 200, upTv);
}
});
public void show(int int1, int int2, final TextView tv)
{
String button1String = "OK";
String button2String = "cancell";
ad = new AlertDialog.Builder(MonitorActivity.this);
ad.setTitle("Title");
final NumberPicker picker = new NumberPicker(MonitorActivity.this);
picker.setMinValue(int1);
picker.setMaxValue(int2);
picker.setWrapSelectorWheel(false);
final FrameLayout parent = new FrameLayout(MonitorActivity.this);
parent.addView(picker, new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT,
Gravity.CENTER));
ad.setView(parent);
ad.setPositiveButton(button1String, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int arg1) {
int pickedValue = picker.getValue();
tv.setText(String.valueOf(picker.getValue()));
picker.setValue(pickedValue);
}
});
ad.setNegativeButton(button2String, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int arg1) {
}
});
ad.setCancelable(true);
ad.show();
}
が必要ですか?完全なコードを投稿してください。 –
@NigamPatroが追加されました – MrStuff88
ここでの問題点は、表示するときにvauleを設定していないことです。 setMaxValue()の後にデフォルト値をshow()とsetValue()に渡す必要があります。 –