Как установить фокус на часы в `TimePicker` в` onCreate`? [Дубликат]

Вы можете использовать эту пользовательскую библиотеку (написанную с помощью Promise) для выполнения удаленного вызова.

function $http(apiConfig) {
    return new Promise(function (resolve, reject) {
        var client = new XMLHttpRequest();
        client.open(apiConfig.method, apiConfig.url);
        client.send();
        client.onload = function () {
            if (this.status >= 200 && this.status < 300) {
                // Performs the function "resolve" when this.status is equal to 2xx.
                // Your logic here.
                resolve(this.response);
            }
            else {
                // Performs the function "reject" when this.status is different than 2xx.
                reject(this.statusText);
            }
        };
        client.onerror = function () {
            reject(this.statusText);
        };
    });
}

Пример простого использования:

$http({
    method: 'get',
    url: 'google.com'
}).then(function(response) {
    console.log(response);
}, function(error) {
    console.log(error)
});
5
задан Juni 14 March 2015 в 06:27
поделиться

1 ответ

Вы можете получить каждый NumberPicker TimePicker и сделать все, что хотите, например, изменить, запросить фокус и т. д.

NumberPicker hourPicker = (NumberPicker) mTimePicker.findViewById(Resources.getSystem().getIdentifier("hour",
     "id", "android"));

NumberPicker minutePicker = (NumberPicker) mTimePicker.findViewById(Resources.getSystem().getIdentifier("minute",
     "id", "android"));

NumberPicker amPmPicker = (NumberPicker) mTimePicker.findViewById(Resources.getSystem().getIdentifier("amPm",
     "id", "android"));

// this is a number picker modified and there is one for each NumerPicker above
View numberPickerModified = (View) mTimePicker.findViewById(Resources.getSystem().getIdentifier("numberpicker_input",
     "id", "android"));
6
ответ дан Lennon Petrick 25 August 2018 в 22:34
поделиться
Другие вопросы по тегам:

Похожие вопросы: