当前位置: 首页>>代码示例>>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;未经允许,请勿转载。