[英]Cannot resolve symbol setMinValue
I am trying to use a NumberPicker in Android Studio. 我想在Android Studio中使用NumberPicker。 Yet when I try to use setMinValue(), it gives me an error saying "Cannot resolve symbol setMinValue."
然而,当我尝试使用setMinValue()时,它给出了一个错误,说“无法解析符号setMinValue”。 According to ( https://developer.android.com/reference/android/widget/NumberPicker.html ), setMinValue() is a valid function for NumberPicker.
根据( https://developer.android.com/reference/android/widget/NumberPicker.html ),setMinValue()是NumberPicker的有效函数。 I have tried Build -> Clean Project and that did not work either.
我尝试过Build - > Clean Project,但也没用。 Please help me!
请帮我!
My code is: 我的代码是:
NumberPicker picker = (NumberPicker) findViewByID (R.id.LanguagePicker); String[] things = new String[] ("this", "that"); picker.setMinValue(0);
It should work. 它应该工作。
I used this way once to make time picker 我用这种方式一次做时间选择器
NumberPicker myTimeHour = (NumberPicker) myView.findViewById(R.id.time_hour);
NumberPicker myTimeMinutes = (NumberPicker) myView.findViewById(R.id.time_minutes);
myTimeMinutes.setMinValue(0);
myTimeMinutes.setMaxValue(getResources().getStringArray(R.array.minutes_item).length - 1);
myTimeMinutes.setDisplayedValues(getResources().getStringArray(R.array.minutes_item));
myTimeHour.setMinValue(0);
myTimeHour.setMaxValue(getResources().getStringArray(R.array.hour_item).length - 1);
myTimeHour.setDisplayedValues(getResources().getStringArray(R.array.hour_item));
For your situation, the code should be the following 根据您的情况,代码应如下所示
NumberPicker picker = (NumberPicker) myView.findViewById(R.id.LanguagePicker);
myTimeMinutes.setMinValue(0);
myTimeMinutes.setMaxValue(1);
myTimeMinutes.setDisplayedValues(new String[]{"this", "that"});
The documentation show the following about max value: The length of the displayed values array set via setDisplayedValues(String[]) must be equal to the range of selectable numbers which is equal to getMaxValue() - getMinValue() + 1. 文档显示以下关于最大值的值: 通过setDisplayedValues(String [])设置的显示值数组的长度必须等于可选数字的范围,其等于getMaxValue() - getMinValue()+ 1。
Please attach entire code and stack trace errors 请附上整个代码和堆栈跟踪错误
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.