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
    selenium
    解决servlet响应乱码问题
    flask后端的跨域问题
    python中并发----线程的启动和停止
    react-native 自定义组件规范
    react-native 高阶组件笔记
    class-dump安装及使用
    jekyll的安装
    取巧的json转model声明代码的工具
  • 原文地址:https://www.cnblogs.com/luckygxf/p/3934990.html
Copyright © 2011-2022 走看看