本文整理汇总了Java中android.widget.NumberPicker.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java NumberPicker.getValue方法的具体用法?Java NumberPicker.getValue怎么用?Java NumberPicker.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.NumberPicker
的用法示例。
在下文中一共展示了NumberPicker.getValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: NumberPickerAnswered
import android.widget.NumberPicker; //导入方法依赖的package包/类
/**
* Auxiliar function to get questions 8 to 10 value and set an error if they have not been
* answered.
*
* @param i Number of question
* @param id {@link RatingStars} id
* @param text {@link TextView} id of the question title
* @param error {@link TextView} title of the first question title whose question has an error
* @return <code>true</code> if an error was set; <code>false</code> otherwise.
*/
private TextView NumberPickerAnswered(int i, int id, int text, TextView error) {
NumberPicker np = (NumberPicker) findViewById(id);
int value = np.getValue();
TextView tv = (TextView) findViewById(text);
if (value == 0) {
tv.setError("");
if (error == null) {
return tv;
}
} else {
questions[i] = ((i == 7) ? (value - 1) * 10 : (value - 1));
tv.setError(null);
}
return error;
}
示例2: hasNumberPickerDisplayedValue
import android.widget.NumberPicker; //导入方法依赖的package包/类
public static Matcher<View> hasNumberPickerDisplayedValue(final Matcher<String> stringMatcher) {
return new BoundedMatcher<View, NumberPicker>(NumberPicker.class) {
@Override
public void describeTo(final Description description) {
description.appendText("With number picker displayed value: ");
stringMatcher.describeTo(description);
}
@Override
public boolean matchesSafely(final NumberPicker view) {
int index = view.getValue();
String[] displayedValues = view.getDisplayedValues();
return stringMatcher.matches(displayedValues[index-1]);
}
};
}
示例3: onScrollStateChange
import android.widget.NumberPicker; //导入方法依赖的package包/类
@Override
public void onScrollStateChange(NumberPicker view, int scrollState) {
this.scrollState_p = scrollState;
int pos = getAdapterPosition();
Log.d("zpos",String.valueOf(pos));
Log.d("zScrollState",String.valueOf(scrollState));
if (scrollState == SCROLL_STATE_IDLE){
int actual_value = view.getValue();
int adapterPosition = getAdapterPosition();
String obj = mObjectsToCount.get(adapterPosition);
mClickHandler.onValueChanged(obj, actual_value);
}
}
示例4: getValue
import android.widget.NumberPicker; //导入方法依赖的package包/类
public int getValue()
{
int num = 0;
for(NumberPicker p : pickers)
{
num = num*10 + p.getValue();
}
return num;
}
示例5: setResult
import android.widget.NumberPicker; //导入方法依赖的package包/类
void setResult() {
EditText et = (EditText)findViewById(R.id.age);
String checkEmpty = et.getText().toString();
RadioGroup rg = (RadioGroup)findViewById(R.id.gender);
RadioGroup rg2 = (RadioGroup)findViewById(R.id.reoccur);
RadioButton rb1 = (RadioButton)findViewById(R.id.male);
RadioButton rb2 = (RadioButton)findViewById(R.id.yes);
NumberPicker numberPicker = (NumberPicker) findViewById(R.id.numberPicker);
NumberPicker stringPicker = (NumberPicker) findViewById(R.id.stringPicker);
Intent intent = new Intent();
if (checkEmpty.matches("")){
Toast.makeText(AgeScreen.this, "Age not set!",
Toast.LENGTH_LONG).show();
setResult(RESULT_CANCELED, intent);
} else if (rg.getCheckedRadioButtonId() == -1) {
Toast.makeText(AgeScreen.this, "Gender not selected!",
Toast.LENGTH_LONG).show();
setResult(RESULT_CANCELED, intent);
} else if (rg2.getCheckedRadioButtonId() == -1) {
Toast.makeText(AgeScreen.this, "Recurrence not selected!",
Toast.LENGTH_LONG).show();
setResult(RESULT_CANCELED, intent);
} else {
//age
intent.putExtra("age",Integer.parseInt(checkEmpty));
//gender
if (rb1.isChecked())
intent.putExtra("gender","male");
else
intent.putExtra("gender","female");
//reoccurring
if (rb2.isChecked())
intent.putExtra("reoccurring",true);
else
intent.putExtra("reoccurring",false);
//days
int days = numberPicker.getValue();
int date = stringPicker.getValue();
if (date == 2)
days *= 28; //months selected
else if (date == 3)
days *= 365; //years selected
intent.putExtra("days",days);
setResult(RESULT_OK, intent);
}
finish();
}
示例6: getPickerValue
import android.widget.NumberPicker; //导入方法依赖的package包/类
/**
* Clear focus before retrieving so that values inserted with
* keyboard are taken into account.
*/
private int getPickerValue(NumberPicker picker) {
picker.clearFocus();
return picker.getValue();
}