android.widget.TimePicker.setOnTimeChangedListener()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(110)

本文整理了Java中android.widget.TimePicker.setOnTimeChangedListener()方法的一些代码示例,展示了TimePicker.setOnTimeChangedListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TimePicker.setOnTimeChangedListener()方法的具体详情如下:
包路径:android.widget.TimePicker
类名称:TimePicker
方法名:setOnTimeChangedListener

TimePicker.setOnTimeChangedListener介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

TimePicker tp = (TimePicker)dialog.findViewById(R.id.timepicker1);
tp.setOnTimeChangedListener(myOnTimechangedListener);

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.main);
 TimePicker picker=(TimePicker)findViewById(R.id.picker);
 picker.setOnTimeChangedListener(this);
}

代码示例来源:origin: stackoverflow.com

timePicker.setOnTimeChangedListener(new OnTimeChangedListener() {
  @Override
  public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {

代码示例来源:origin: Joysing/AlipayAutoGetForest

private void initListener() {
  timepick.setOnTimeChangedListener(this);
}

代码示例来源:origin: stackoverflow.com

TimePicker tp = (TimePicker)dialog.findViewById(R.id.timepicker1);
tp.setOnTimeChangedListener(myOnTimechangedListener);

代码示例来源:origin: stackoverflow.com

final TimePicker tp = (TimePicker)promptsView.findViewById(R.id.timepicker1);
tp.setOnTimeChangedListener(timeChangedListener);

代码示例来源:origin: stackoverflow.com

TimePicker tp = (TimePicker)dialog.findViewById(R.id.timepicker1);
tp.setOnTimeChangedListener(myOnTimechangedListener);

代码示例来源:origin: stackoverflow.com

private void updateDisplay(TimePicker timePicker, Date date, int hourOfDay, int minute) 
{ 
  nextMinute = nextMinute+5;

  // remove ontimechangedlistener to prevent stackoverflow/infinite loop
  timePicker.setOnTimeChangedListener(mNullTimeChangedListener);

  // set minute
  timePicker.setCurrentMinute(nextMinute);

  // look up ontimechangedlistener again
  timePicker.setOnTimeChangedListener(mStartTimeChangedListener);

  // update the date variable for use elsewhere in code
  date.setMinutes(nextMinute);  
}

代码示例来源:origin: WangDaYeeeeee/Mysplash

private void initWidget(View view) {
  this.container = view.findViewById(R.id.dialog_time_picker_container);
  Button done = view.findViewById(R.id.dialog_time_picker_done);
  done.setOnClickListener(this);
  Button cancel = view.findViewById(R.id.dialog_time_picker_cancel);
  cancel.setOnClickListener(this);
  TimePicker timePicker = view.findViewById(R.id.dialog_time_picker_time_picker);
  timePicker.setIs24HourView(true);
  timePicker.setOnTimeChangedListener(this);
}

代码示例来源:origin: WangDaYeeeeee/GeometricWeather

private void initWidget(View view) {
  this.container = (CoordinatorLayout) view.findViewById(R.id.dialog_time_setter_container);
  Button done = (Button) view.findViewById(R.id.dialog_time_setter_done);
  done.setOnClickListener(this);
  Button cancel = (Button) view.findViewById(R.id.dialog_time_setter_cancel);
  cancel.setOnClickListener(this);
  TimePicker timePicker = (TimePicker) view.findViewById(R.id.dialog_time_setter_time_picker);
  timePicker.setIs24HourView(true);
  timePicker.setOnTimeChangedListener(this);
}

代码示例来源:origin: stackoverflow.com

public class TimePickerDemoActivity extends Activity implements
  OnTimeChangedListener {
 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);

  TimePicker picker=(TimePicker)findViewById(R.id.picker);

  picker.setOnTimeChangedListener(this);
 }

 @Override
 public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
  Calendar then=Calendar.getInstance();

  then.set(Calendar.HOUR_OF_DAY, hourOfDay);
  then.set(Calendar.MINUTE, minute);
  then.set(Calendar.SECOND, 0);

  Toast.makeText(this, then.getTime().toString(), Toast.LENGTH_SHORT)
     .show();
 }
}

代码示例来源:origin: stackoverflow.com

public class MainActivity extends Activity 
  implements TimePicker.OnTimeChangedListener {

  private TextView resultTime;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    resultTime = (TextView) findViewById(R.id.activity_main_textview_resulttime);

    TimePicker timePicker = (TimePicker) findViewById(R.id.activity_main_timepicker);
    {    
      timePicker.setIs24HourView(true);
      timePicker.setOnTimeChangedListener(this);
    }
  }

  @Override
  public void onTimeChanged(TimePicker timePickerView, int hours, int minutes) {
    final String stringNewTime = hours + " : " + minutes;
    resultTime.setText(stringNewTime);
  }   
}

代码示例来源:origin: stackoverflow.com

timePicker.setOnTimeChangedListener(mNullTimeChangedListener);
timePicker.setOnTimeChangedListener(mStartTimeChangedListener);

代码示例来源:origin: jclehner/rxdroid

@Override
protected View onCreateDialogView()
{
  if(mContainer == null)
  {
    mContainer = getLayoutInflater().inflate(R.layout.time_period_preference, null);
    mMessageView = (TextView) mContainer.findViewById(R.id.message);
    mTimePicker = (TimePicker) mContainer.findViewById(R.id.picker);
    mTimePicker.setIs24HourView(DateFormat.is24HourFormat(getContext()));
    mTimePicker.setOnTimeChangedListener(mTimeListener);
  }
  return mContainer;
}

代码示例来源:origin: jclehner/rxdroid

private void onPageChanged(int page)
{
  if(mCurrentPage != page)
    mCurrentPage = page;
  // Util.setTimePickerTime() would cause the listener to
  // be called, so we temporarily replace it with a dummy.
  mTimePicker.setOnTimeChangedListener(mTimeListenerDummy);
  if(page == BEGIN)
  {
    mBackButton.setText(android.R.string.cancel);
    mNextButton.setText(R.string._btn_next);
    Util.setTimePickerTime(mTimePicker, mBegin);
  }
  else if(page == END)
  {
    mBackButton.setText(R.string._btn_back);
    mNextButton.setText(android.R.string.ok);
    Util.setTimePickerTime(mTimePicker, mEnd);
  }
  final Dialog dialog = getDialog();
  if(dialog != null)
  {
    final int[] titleIds = { R.string._title_begin, R.string._title_end };
    dialog.setTitle(getTitle() + " - " + getContext().getString(titleIds[page]));
  }
  mTimePicker.setOnTimeChangedListener(mTimeListener);
  updateMessageAndButtons();
}

代码示例来源:origin: quemb/QMBForm

@SuppressWarnings("deprecation")
@Override
protected void initDatePicker(Calendar calendar) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
  {
    mTimePicker.setHour(calendar.get(Calendar.HOUR_OF_DAY));
    mTimePicker.setMinute(calendar.get(Calendar.MINUTE));
  }
  else
  {
    mTimePicker.setCurrentHour(calendar.get(Calendar.HOUR_OF_DAY));
    mTimePicker.setCurrentMinute(calendar.get(Calendar.MINUTE));
  }
  mTimePicker.setOnTimeChangedListener(this);
  if (DateFormat.is24HourFormat(getContext()))
      mTimePicker.setIs24HourView(true);
}

代码示例来源:origin: THEONE10211024/ApiDemos

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.date_widgets_example_2);
  TimePicker timePicker = (TimePicker) findViewById(R.id.timePicker);
  timePicker.setCurrentHour(12);
  timePicker.setCurrentMinute(15);
  mTimeDisplay = (TextView) findViewById(R.id.dateDisplay);
  updateDisplay(12, 15);
  timePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {
    public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
      updateDisplay(hourOfDay, minute);
    }
  });
}

代码示例来源:origin: qiubiteme/android_api_demos

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.date_widgets_example_2);
  TimePicker timePicker = (TimePicker) findViewById(R.id.timePicker);
  timePicker.setCurrentHour(12);
  timePicker.setCurrentMinute(15);
  mTimeDisplay = (TextView) findViewById(R.id.dateDisplay);
  updateDisplay(12, 15);
  timePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {
    public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
      updateDisplay(hourOfDay, minute);
    }
  });
}

代码示例来源:origin: dsolonenko/financisto

@Override
protected View onCreateDialogView() {
  Context context = getContext();
  TimePicker timePicker = new TimePicker(context);
  timePicker.setIs24HourView(is24HourFormat(context));
  timePicker.setOnTimeChangedListener(this);
  timePicker.setCurrentHour(getHour());
  timePicker.setCurrentMinute(getMinute());
  return timePicker;
}

代码示例来源:origin: mathisdt/trackworktime

private void updateDateAndTimePickers(DateTime dateTime) {
  time.setCurrentHour(dateTime.getHour());
  time.setCurrentMinute(dateTime.getMinute());
  if (pickersAreInitialized) {
    date.updateDate(dateTime.getYear(), dateTime.getMonth() - 1, dateTime.getDay());
  } else {
    time.setOnTimeChangedListener(this);
    date.init(dateTime.getYear(), dateTime.getMonth() - 1, dateTime.getDay(), this);
    pickersAreInitialized = true;
    // manually set the variables once:
    selectedHour = dateTime.getHour();
    selectedMinute = dateTime.getMinute();
    selectedYear = dateTime.getYear();
    selectedMonth = dateTime.getMonth() - 1;
    selectedDay = dateTime.getDay();
    setWeekday();
  }
}

相关文章