當前位置: 首頁>>代碼示例>>Java>>正文


Java DatePicker.setCalendarViewShown方法代碼示例

本文整理匯總了Java中android.widget.DatePicker.setCalendarViewShown方法的典型用法代碼示例。如果您正苦於以下問題:Java DatePicker.setCalendarViewShown方法的具體用法?Java DatePicker.setCalendarViewShown怎麽用?Java DatePicker.setCalendarViewShown使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.DatePicker的用法示例。


在下文中一共展示了DatePicker.setCalendarViewShown方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: show

import android.widget.DatePicker; //導入方法依賴的package包/類
public AlertDialog show(Context context) {
    dialog = new AlertDialog.Builder(context).create();
    dialog.show();
    Window window = dialog.getWindow();
    window.setContentView(R.layout.dialog_date_time);
    window.setGravity(Gravity.CENTER);// 此處可以設置dialog顯示的位置
    //window.setWindowAnimations(R.style.in_left_out_right_style);
    window.setBackgroundDrawableResource(R.color.transparent);

    datePicker = (DatePicker) window
            .findViewById(R.id.date_time_datePicker1);
    datePicker.setCalendarViewShown(false);
    timePicker = (TimePicker) window.findViewById(R.id.date_time_timePicker);
    but_ok = (Button) window.findViewById(R.id.date_time_but_ok);
    but_ok.setOnClickListener(this);
    return dialog;
}
 
開發者ID:abook23,項目名稱:godlibrary,代碼行數:18,代碼來源:DialogDate.java

示例2: onCreateDialog

import android.widget.DatePicker; //導入方法依賴的package包/類
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Uses the current date as the default date in the picker
    Calendar c = Calendar.getInstance();
    int year = c.get(Calendar.YEAR);
    int month = c.get(Calendar.MONTH);
    int day = c.get(Calendar.DAY_OF_MONTH);
    DatePickerDialog dialog = new DatePickerDialog(getActivity(), this, year, month, day);
    DatePicker datePicker = dialog.getDatePicker();

    datePicker.setCalendarViewShown(false);
    numOfCalls = 0;

    return dialog;
}
 
開發者ID:mr-kojo,項目名稱:Veggietizer,代碼行數:17,代碼來源:DatePickerFragment.java

示例3: pickMonth

import android.widget.DatePicker; //導入方法依賴的package包/類
/**
 * 年月選擇對話框
 *
 * @param con
 * @param title
 * @param calendar
 * @param listener
 */
public static void pickMonth(Context con, String title, Calendar calendar, final OnDateSetListener listener) {
    LinearLayout ll = new LinearLayout(con);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    ll.setLayoutParams(layoutParams);
    ll.setOrientation(LinearLayout.VERTICAL);
    //添加一條線
    LinearLayout line = new LinearLayout(con);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1);
    line.setBackgroundColor(con.getResources().getColor(R.color.line));
    line.setLayoutParams(lp);
    ll.addView(line);
    //添加選擇器控件
    final DatePicker datePicker = new DatePicker(con, null, themeId);
    datePicker.setLayoutParams(layoutParams);
    datePicker.init(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), null);
    datePicker.setCalendarViewShown(false);
    ll.addView(datePicker);
    //初始化對話框
    QuickDialog.Builder builder = new QuickDialog.Builder(con);
    builder.setContentView(ll);
    builder.setTitle(title);
    builder.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            listener.onDateSet(datePicker, datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth());
        }
    });
    builder.create().show();
}
 
開發者ID:quickhybrid,項目名稱:quickhybrid-android,代碼行數:39,代碼來源:DialogUtil.java

示例4: hideDay

import android.widget.DatePicker; //導入方法依賴的package包/類
/**
 * 隱藏日,隻選擇年月
 */
public void hideDay() {
    if (Build.VERSION.SDK_INT >= 24) {
        try {
            final Field field = this.findField(DatePickerDialog.class,
                    DatePicker.class, "mDatePicker");

            DatePicker datePicker = (DatePicker) field.get(this);
            final Class<?> delegateClass = Class
                    .forName("android.widget.DatePicker$DatePickerDelegate");
            final Field delegateField = this.findField(DatePicker.class,
                    delegateClass, "mDelegate");

            final Object delegate = delegateField.get(datePicker);
            final Class<?> spinnerDelegateClass = Class
                    .forName("android.widget.DatePickerSpinnerDelegate");

            if (delegate.getClass() != spinnerDelegateClass) {
                delegateField.set(datePicker, null);
                datePicker.removeAllViews();

                final Constructor spinnerDelegateConstructor = spinnerDelegateClass
                        .getDeclaredConstructor(DatePicker.class,
                                Context.class, AttributeSet.class,
                                int.class, int.class);
                spinnerDelegateConstructor.setAccessible(true);

                final Object spinnerDelegate = spinnerDelegateConstructor
                        .newInstance(datePicker, con, null,
                                android.R.attr.datePickerStyle, 0);
                delegateField.set(datePicker, spinnerDelegate);

                datePicker.init(year, monthOfYear, dayOfMonth, this);
                datePicker.setCalendarViewShown(false);
                datePicker.setSpinnersShown(true);
            }
        } catch (Exception e) { /* Do nothing */
        }
    } else {
        ((ViewGroup) ((ViewGroup) getDatePicker().getChildAt(0)).getChildAt(0)).getChildAt(2).setVisibility(View.GONE);
    }
}
 
開發者ID:quickhybrid,項目名稱:quickhybrid-android,代碼行數:45,代碼來源:QuickDatePickerDialog.java

示例5: setShowCalendar

import android.widget.DatePicker; //導入方法依賴的package包/類
/**
 * Show the calendar view
 * @param picker
 * @param show default is false
 */
@ReactProp(name="showCalendar", defaultBoolean = false)
public void setShowCalendar(DatePicker picker, boolean show) {
    picker.setCalendarViewShown(show);
    picker.setSpinnersShown(!show);
}
 
開發者ID:vincentsong,項目名稱:react-native-datepicker-component-android,代碼行數:11,代碼來源:RNDatePickerComponentViewManager.java


注:本文中的android.widget.DatePicker.setCalendarViewShown方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。