zoukankan      html  css  js  c++  java
  • android继承Dialog实现自定义对话框

    有时需要自定义对话框,可以使用AlterDialog.Bulider,比如下面的代码片段

    1 new AlertDialog.Builder(self)  
    2 
    3                 .setTitle("标题")
    4 
    5                 .setMessage("简单消息框")
    6 
    7                 .setPositiveButton("确定", null)
    8 
    9                 .show();

    上面的代码片段来自:http://blog.csdn.net/chenlei1889/article/details/6267406

    这里我要记录的是通过继承Dialog这个类,实现自定义对话框

    布局文件menu.xml放在layout文件夹下面

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content">
        <TextView
            android:text="用户名"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="20sp" 
        />
        <EditText
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/user" 
        />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="密码"
            android:textSize="20sp" 
        />
        <EditText
            android:id="@+id/password"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:password="true"
        />
    </LinearLayout>

    java代码(片段)

    1 MyDialog myDialog = new MyDialog(Activity_First.this);
    2                     myDialog.show();
  • 相关阅读:
    MySQL远程登陆
    一键安装LAMP wordpress
    编译安装httpd2.4.46
    RDB转化AOF 花式删库
    3周作业
    2周作业
    1周作业
    预习第三周作业
    预习第二周作业
    预习第一周作业
  • 原文地址:https://www.cnblogs.com/luckygxf/p/3934990.html
Copyright © 2011-2022 走看看