zoukankan      html  css  js  c++  java
  • 自定义Dialog

    此代码完成一个带有日期和时间功能的Dialog

    效果图如下:

         AlertDialog.Builder  builder = new AlertDialog.Builder(MeettingManage_1.this);   

      LayoutInflater factory = LayoutInflater.from(MeettingManage_1.this);  

         final View textEntryView = factory.inflate(R.layout.meettime_date_dialog, null);      

         builder.setTitle("选择时间");      

         builder.setView(textEntryView);      

         builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {

                                                   public void onClick(DialogInterface dialog, int whichButton) {

                                                            TimePicker timePicker = (TimePicker)textEntryView.findViewById(R.id.timepicker);

                                                            DatePicker datePicker = (DatePicker)textEntryView.findViewById(R.id.datepicker);

                                                            timeEditText.setText(datePicker.getYear()+"-"+(datePicker.getMonth()+1)+"-"+datePicker.getDayOfMonth()+"     "+timePicker.getCurrentHour()+":"+timePicker.getCurrentMinute()+"");

                                                            }      

                                                   });

                                         builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {

                                                   public void onClick(DialogInterface dialog, int whichButton) {

                                                           

                                                   }      

                                                   });    

                                         builder.create().show();

    XML文件:

    <?xml version="1.0" encoding="utf-8"?>

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

        android:layout_width="fill_parent"

        android:layout_height="fill_parent"

        android:background="#e6f5fa"

        android:orientation="vertical" >

        <TimePicker

              android:id="@+id/timepicker"

              android:layout_width="wrap_content"

              android:layout_height="wrap_content"/>

           <DatePicker

                  android:id="@+id/datepicker"

              android:layout_width="wrap_content"

              android:layout_height="wrap_content" />

    </LinearLayout>

  • 相关阅读:
    CSS3 非线性时间函数应用
    CSS3 animation动画与transition过渡比较
    JS 数组高阶函数 map、reduce、filter、sort等
    访问控制列表-ACL匹配规则
    C 函数——Day04
    让你的wordpress在新窗口打开链接
    EFI、UEFI、MBR、GPT的区别
    C 输入 & 输出——Day03
    C 数据类型——Day02
    博客园代码高亮
  • 原文地址:https://www.cnblogs.com/wubingshenyin/p/2705966.html
Copyright © 2011-2022 走看看