bl双性强迫侵犯h_国产在线观看人成激情视频_蜜芽188_被诱拐的少孩全彩啪啪漫画

datepicterDialog和timepicterDialog取消按鈕

這是日期彈出框的第一種彈出方式:分開彈出datepicterdialog和timepicterdialog

創新互聯建站是一家專注于成都網站設計、做網站與策劃設計,臺山網站建設哪家好?創新互聯建站做網站,專注于網站建設10多年,網設計領域的專業建站公司;建站業務涵蓋:臺山等地區。臺山做網站價格咨詢:18980820575

 

final DatePickerDialog datePickerDialog = new DatePickerDialog(
       TableChart.this, null, mYear, mMonth,
       mDay);
     datePickerDialog.setButton(DialogInterface.BUTTON_POSITIVE,
       "完成", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface arg0,
          int arg1) {
         DateTimeUtils.showDatePositive(datePickerDialog,starttime);
        }
       });
     datePickerDialog.setButton(DialogInterface.BUTTON_NEGATIVE,
       "取消", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface arg0,
          int arg1) {
         DateTimeUtils.showDateNegative(starttime);
        }
       });
     datePickerDialog.setCanceledOnTouchOutside(false);
     datePickerDialog.show();
 
public static void showDatePositive(DatePickerDialog datePickerDialog,
   EditText yearEdit) {
  DatePicker datePicker = datePickerDialog.getDatePicker();//獲取DatePicter對象
  int year = datePicker.getYear();
  int month = datePicker.getMonth() + 1;
  int day = datePicker.getDayOfMonth();
  yearEdit.setText(year+"-"month+"-"+day);
  yearEdit.clearFocus();
  }
public static void showDateNegative(EditText yearEdit) {
  yearEdit.clearFocus();
  }
由于timepicterDialog無法獲取到timepicter,所以重寫:MyTimePickerDialog.java
package com.rts.dzdc.utils;
import com.rts.dzdc.activity.R;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TimePicker;
import android.widget.TimePicker.OnTimeChangedListener;
/**
* 基本上把源碼套用了一下
* @author Lee
*
*/
public class MyTimePickerDialog extends AlertDialog
        implements OnClickListener, OnTimeChangedListener {
public interface OnTimeSetListener {
        void onTimeSet(TimePicker view, int hourOfDay, int minute);
    }
    private static final String HOUR = "hour";
    private static final String MINUTE = "minute";
    private static final String IS_24_HOUR = "is24hour";
    private final TimePicker mTimePicker;
    private final OnTimeSetListener mCallback;
    int mInitialHourOfDay;
    int mInitialMinute;
    boolean mIs24HourView;
  
    public MyTimePickerDialog(Context context,
            OnTimeSetListener callBack,
            int hourOfDay, int minute, boolean is24HourView) {
        this(context, 0, callBack, hourOfDay, minute, is24HourView);
    }
  
    public MyTimePickerDialog(Context context,
            int theme,
            OnTimeSetListener callBack,
            int hourOfDay, int minute, boolean is24HourView) {
        super(context, theme);
        mCallback = callBack;
        mInitialHourOfDay = hourOfDay;
        mInitialMinute = minute;
        mIs24HourView = is24HourView;
        setIcon(0);
        setTitle("設置時間");
        Context themeContext = getContext();
        setButton(BUTTON_POSITIVE, "完成", this);
        LayoutInflater inflater =
                (LayoutInflater) themeContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.time_picker_dialog, null);
        setView(view);
        mTimePicker = (TimePicker) view.findViewById(R.id.timePicker);
        // initialize state
        mTimePicker.setIs24HourView(mIs24HourView);
        mTimePicker.setCurrentHour(mInitialHourOfDay);
        mTimePicker.setCurrentMinute(mInitialMinute);
        mTimePicker.setOnTimeChangedListener(this);
    }
    public void onClick(DialogInterface dialog, int which) {
        tryNotifyTimeSet();
    }
    public void updateTime(int hourOfDay, int minutOfHour) {
        mTimePicker.setCurrentHour(hourOfDay);
        mTimePicker.setCurrentMinute(minutOfHour);
    }
    public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
        /* do nothing */
    }
    private void tryNotifyTimeSet() {
        if (mCallback != null) {
            mTimePicker.clearFocus();
            mCallback.onTimeSet(mTimePicker, mTimePicker.getCurrentHour(),
                    mTimePicker.getCurrentMinute());
        }
    }
    @Override
    protected void onStop() {
        tryNotifyTimeSet();
        super.onStop();
    }
    @Override
    public Bundle onSaveInstanceState() {
        Bundle state = super.onSaveInstanceState();
        state.putInt(HOUR, mTimePicker.getCurrentHour());
        state.putInt(MINUTE, mTimePicker.getCurrentMinute());
        state.putBoolean(IS_24_HOUR, mTimePicker.is24HourView());
        return state;
    }
    @Override
    public void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        int hour = savedInstanceState.getInt(HOUR);
        int minute = savedInstanceState.getInt(MINUTE);
        mTimePicker.setIs24HourView(savedInstanceState.getBoolean(IS_24_HOUR));
        mTimePicker.setCurrentHour(hour);
        mTimePicker.setCurrentMinute(minute);
    }
   
    /**
     * 自己加的獲取TimePicker方法
     * @return
     */
    public TimePicker getTimePicker()
    {
     return mTimePicker;
    }
}
使用方法:
final MyTimePickerDialog timePickerDialog = new MyTimePickerDialog(
         TableSlideZaiHaiActivity.this, null,
         mhour, mmintue, true);
       timePickerDialog.setButton(DialogInterface.BUTTON_POSITIVE,
         "完成", new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface arg0,
            int arg1) {
           DateTimeUtils.showTimePositive(timePickerDialog,hour);
          }
         });
       timePickerDialog.setButton(DialogInterface.BUTTON_NEGATIVE,
         "取消", new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface arg0,
            int arg1) {
           DateTimeUtils.showTimeNegative(slidedown_huadongtimehour);
          }
         });
       timePickerDialog.setCanceledOnTouchOutside(false);
       timePickerDialog.show();
      
       public static void showTimePositive(MyTimePickerDialog timePickerDialog,EditText hourEdit) {
  TimePicker timePicker = timePickerDialog.getTimePicker();
  int hour = timePicker.getCurrentHour();
  int mintue = timePicker.getCurrentMinute();
  hourEdit.setText(hour+":"+mintue);
   hourEdit.clearFocus();
   }
public static void showTimeNegative(EditText hourEdit, EditText ) {
  hourEdit.clearFocus();
   }
  

本文名稱:datepicterDialog和timepicterDialog取消按鈕
鏈接分享:http://vcdvsql.cn/article24/iipsje.html

成都網站建設公司_創新互聯,為您提供服務器托管全網營銷推廣網站收錄企業網站制作網站維護虛擬主機

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

網站優化排名