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>

  • 相关阅读:
    3. applicationCache
    9. 水平垂直居中的方法
    2. 贝塞尔曲线bezierCurveTo
    相识python 之小数据池 集合
    相识python --------- 列表 元祖 range 范围
    相识python while循环 代码块 编码初识 运算符
    相识python第二步:变量 注释 str int bool 用户交换 流程控制语句的解释用法
    python学习基础知识
    python的基础知识
    我对python的见解
  • 原文地址:https://www.cnblogs.com/wubingshenyin/p/2705966.html
Copyright © 2011-2022 走看看