Java Code Examples for android.widget.NumberPicker#getValue()

The following examples show how to use android.widget.NumberPicker#getValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestActivity.java    From medical-data-android with GNU General Public License v3.0 8 votes vote down vote up
/**
 * 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;
}
 
Example 2
Source File: MultiFieldTimePickerDialog.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Clear focus before retrieving so that values inserted with
 * keyboard are taken into account.
*/
private int getPickerValue(NumberPicker picker) {
    picker.clearFocus();
    return picker.getValue();
}