Ejemplo n.º 1
0
 private void handleExpansion(Button buttonClicked, DatePicker datePicker) {
   if (datePicker.getVisibility() == View.GONE) {
     datePicker.setVisibility(View.VISIBLE);
   } else {
     datePicker.setVisibility(View.GONE);
     String date = getDateFromDatePicker(datePicker);
     buttonClicked.setText(date);
   }
 }
Ejemplo n.º 2
0
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    Logger.D(TAG, "onCreate");

    getWindow().setFlags(RhodesService.WINDOW_FLAGS, RhodesService.WINDOW_MASK);
    setContentView(AndroidR.layout.datetime);

    Bundle extras = this.getIntent().getExtras();

    _callback = extras.getString(INTENT_EXTRA_PREFIX + "callback");
    _init = new Date(extras.getLong(INTENT_EXTRA_PREFIX + "init") * 1000);
    _fmt = extras.getInt(INTENT_EXTRA_PREFIX + "fmt");
    _opaque = extras.getByteArray(INTENT_EXTRA_PREFIX + "opaque");

    this.setTitle(extras.getString(INTENT_EXTRA_PREFIX + "title"));

    _datePicker = (DatePicker) findViewById(AndroidR.id.datePicker);
    _timePicker = (TimePicker) findViewById(AndroidR.id.timePicker);
    _okButton = (Button) findViewById(AndroidR.id.okButton);
    _cancelButton = (Button) findViewById(AndroidR.id.cancelButton);

    _okButton.setOnClickListener(mOkListener);
    _cancelButton.setOnClickListener(mCancelListener);

    _datePicker.init(_init.getYear() + 1900, _init.getMonth(), _init.getDay(), null);
    _timePicker.setCurrentHour(_init.getHours());
    _timePicker.setCurrentMinute(_init.getMinutes());

    switch (_fmt) {
      case FORMAT_DATE:
        _timePicker.setVisibility(View.INVISIBLE);
        break;
      case FORMAT_TIME:
        _datePicker.setVisibility(View.INVISIBLE);
        break;
      case FORMAT_DATE_TIME:
        break;
    }
  }
  protected void onCreate(android.os.Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle(R.string.title_choose_time);
    setContentView(R.layout.date_time_layout);
    createmeeting_date_start = (TextView) findViewById(R.id.createmeeting_date_start);
    createmeeting_date_to = (TextView) findViewById(R.id.createmeeting_date_to);
    createmeeting_date = (TextView) findViewById(R.id.createmeeting_date);

    createmeeting_date_start.setText("");
    createmeeting_date_to.setText("");
    createmeeting_date.setText("");
    layout_header = (LinearLayout) findViewById(R.id.layout_header);
    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) layout_header.getLayoutParams();
    params.topMargin = top;
    layout_header.setLayoutParams(params);
    datePicker = (DatePicker) findViewById(R.id.datePicker1);
    timePicker = (TimePicker) findViewById(R.id.timePicker1);

    datePicker.init(
        year,
        month,
        day,
        new OnDateChangedListener() {

          @Override
          public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {

            DateTimeCreateDialog.this.year = year;
            DateTimeCreateDialog.this.month = monthOfYear;
            DateTimeCreateDialog.this.day = dayOfMonth;

            updateTime();
          }
        });

    timePicker.setOnTimeChangedListener(
        new OnTimeChangedListener() {

          @Override
          public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {

            hour = hourOfDay;
            minus = minute;
            updateTime();
          }
        });

    timePicker.setCurrentHour(hour);
    timePicker.setCurrentMinute(minus);

    if (type == CreateType.DAY) {
      timePicker.setVisibility(View.GONE);
      findViewById(R.id.layout_time).setVisibility(View.GONE);
    } else {
      datePicker.setVisibility(View.GONE);
      findViewById(R.id.layout_date).setVisibility(View.GONE);

      if (type == CreateType.TIME_END) {
        findViewById(R.id.layout_start).setVisibility(View.GONE);
      } else {
        findViewById(R.id.layout_end).setVisibility(View.GONE);
      }
    }

    updateTime();

    // TODO
    findViewById(R.id.layout_time).setVisibility(View.GONE);
    findViewById(R.id.layout_time).setVisibility(View.GONE);
  }