<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="用户名"/> <EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"/> </LinearLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="密码"/> <EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"/> </LinearLayout> </LinearLayout>
package com.pingyijinren.helloworld.activity;

import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button; import com.pingyijinren.helloworld.R;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private AlertDialog alertDialog;
private Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button=(Button)findViewById(R.id.button);
button.setOnClickListener(this);
} @Override
public void onClick(View v) {
AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder.setIcon(R.mipmap.ic_launcher);
builder.setTitle("用户登录");
builder.setView(R.layout.alert_dialog_layout);
builder.setPositiveButton("退出", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) { }
});
alertDialog=builder.create();
alertDialog.show();
}
}

AlertDialog自定义的更多相关文章

  1. 获取 AlertDialog自定义的布局 的控件

    AlertDialog自定义的布局 效果图: 创建dialog方法的代码如下: 1 LayoutInflater inflater = getLayoutInflater(); 2 View layo ...

  2. 【转】Android AlertDialog自定义布局

    原文网址:https://blog.csdn.net/u010694658/article/details/53022294 由于开发中经常使用弹框,然而系统自带的弹框太局限,也不太美观,经常不能满足 ...

  3. Android中的AlertDialog使用示例五(自定义对话框)

    在Android开发中,我们经常会需要在Android界面上弹出一些对话框,比如询问用户或者让用户选择.这些功能我们叫它Android Dialog对话框,AlertDialog实现方法为建造者模式. ...

  4. Android之自定义AlertDialog无法监听控件

    参考:http://www.cnblogs.com/511mr/archive/2011/10/21/2220253.html 要做一个自定义的弹出框,以前都是用一个Activity来实现,总觉得不是 ...

  5. 非自定义和自定义Dialog的介绍!!!

    一.非自定义Dialog的几种形式介绍 转自:http://www.kwstu.com/ArticleView/kwstu_20139682354515 前言 对话框对于应用也是必不可少的一个组件,在 ...

  6. 中级实训Android学习记录——Toast、AlertDialog、ProgressBar

    学习记录 2020/11/22 Toast Toast Toast是一个消息提示组件 我们可以设置其显示的位置 自定义其显示的内容 对Toast的简单封装可以达到不同的目的 Toast的默认用法 To ...

  7. Android中使用ExpandableListView实现好友分组

    一个视图显示垂直滚动两级列表中的条目.这不同于列表视图,允许两个层次,类似于QQ的好友分组.要实现这个效果的整体思路为: 1.要给ExpandableListView 设置适配器,那么必须先设置数据源 ...

  8. 【Android】Android--Dialog

    前言 对话框对于应用也是必不可少的一个组件,在Android中也不例外,对话框对于一些提示重要信息,或者一些需要用户额外交互的一些内容很有帮助.本篇博客就讲解一下Android下对话框的使用,在本篇博 ...

  9. 安卓 自定义AlertDialog对话框(加载提示框)

    AlertDialog有以下六种使用方法: 一.简单的AlertDialog(只显示一段简单的信息) 二.带按钮的AlertDialog(显示提示信息,让用户操作) 三.类似ListView的Aler ...

随机推荐

  1. vmware桥接模式下主机有多个网卡导致虚拟机网络不通

    桥接模式下,vmware会绑定一个物理网卡,因此有多个物理网卡时就要注意当前绑定的物理网卡.打开如下vmware菜单 可以看到VMnet0是桥接模式用的,然后他可以选择绑定一个物理网卡,注意要正确选择 ...

  2. configure: error: The LBL Packet Capture Library, libpcap, was not found!

    configure: error:  The LBL Packet Capture Library, libpcap, was not found! yum install libpcap*

  3. EF为什么向我的数据库再次插入已有对象?(ZT)

    最近做了个多对多对实体对象,结果发现每次只要增加一个子实体,就会自动添加一个父实体进去,而不管该父实体是否已经存在. 找了好久,终于找到这篇文章,照文章内容来看,应该是断开连接导致的. 原文地址:ht ...

  4. 聊聊JavaScript和Scala的表达式 Expression

    我们先看下面这段简单的JavaScript代码. 我在第10行调用了函数f,其中传入的第二个和第三个参数都是一个逗号表达式. 函数f的实现,会检查这两个参数的类型,如果是函数,则执行函数调用,再打印其 ...

  5. 用Python爬取智联招聘信息做职业规划

    上学期在实验室发表时写了一个爬取智联招牌信息的爬虫. 操作流程大致分为:信息爬取——数据结构化——存入数据库——所需技能等分词统计——数据可视化 1.数据爬取 job = "通信工程师&qu ...

  6. python之str (字符型)

    用途: 存储少量的数据,+ *int 切片, 其他操作方法 切片还是对其进行任何操作,获取的内容全部是strl类型 存储数据单一 格式: 在python中用引号引起来的就是字符串 '今天吃了没?' 1 ...

  7. docker nginx 负载均衡

    index1.html <html> <head> <title>lb-test</title> </head> <body> ...

  8. SQL Server连接不上本地服务器

    昨天星期一,到公司,如常打开电脑后,上个厕所,吃个早餐,电脑才完全醒来.打开项目后台,发现登不上,用户名或密码错误,认真输入几遍,还是错误,打开本地数据库,sql server连接不上,提示错误: 我 ...

  9. vue的使用配置

    我的编辑器是webstorm,虽然占内容占资源, 但是用起来很方便, 刚开始接触的时候就是用这个软件,很喜欢. vue的教程 1.http://www.jianshu.com/p/5ba253651c ...

  10. NodeJs运行服务器-day01

    //读取内置模块http,这个模块开发服务器用的var http =require('http'); var server=http.createServer(function(req,res){ r ...