0

このチュートリアル ( http://developer.android.com/guide/topics/ui/controls/pickers.html ) から純粋に行くと、ピッカーを簡単に表示できますが、そこから実際の値を取得する方法がわかりません。

public static class TimePickerFragment extends DialogFragment
                        implements TimePickerDialog.OnTimeSetListener {

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        // Use the current time as the default values for the picker
        final Calendar c = Calendar.getInstance();
        int hour = c.get(Calendar.HOUR_OF_DAY);
        int minute = c.get(Calendar.MINUTE);

        // Create a new instance of TimePickerDialog and return it
        return new TimePickerDialog(getActivity(), this, hour, minute,
                DateFormat.is24HourFormat(getActivity()));
    }

    public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
        // Do something with the time chosen by the user
    }
}

public void showTimePickerDialog(View v) {
    DialogFragment newFragment = new TimePickerFragment();
    newFragment.show(getSupportFragmentManager(), "timePicker");
}
4

2 に答える 2

0
hour =timePicker.getCurrentHour();
minute =timePicker.getCurrentMinute();
于 2014-02-04T13:38:26.683 に答える
0

public void onTimeSet(TimePicker view, int hourOfDay, int minute) { // Do something with the time chosen by the user }

この関数は、選択された値を持ちます。

そして、 TimePickerクラスから追加の興味深い機能を取得できます

于 2013-10-15T01:27:51.597 に答える