Par*_*xis 5 user-interface android components android-alertdialog numberpicker
我正在尝试将一个NumberPicker添加到AlertDialog中,但即使看起来没有错误也没有apper.我是Android编码的新手,所以我认为这是一个非常愚蠢的东西.
AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this);
alert.setTitle("Select the value: ");
NumberPicker np = new NumberPicker(MainActivity.this);
String[] nums = new String[100];
for(int i=0; i<nums.length; i++)
nums[i] = Integer.toString(i);
np.setMinValue(1);
np.setMaxValue(nums.length-1);
np.setWrapSelectorWheel(false);
np.setDisplayedValues(nums);
np.setValue(50);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Do something with value!
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Cancel.
}
});
alert.show();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3684 次 |
| 最近记录: |