MainActivity.java文件:

package com.example.shiyan5;

import androidx.appcompat.app.AppCompatActivity;

import android.app.AlertDialog;

import android.content.DialogInterface;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

import android.widget.TableLayout;

import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

//tv_quickReg是快速注册文本框的id;login是弹出的快速注册对话框的布局文件名

TextView tv_quickReg = findViewById(R.id.tv_quickReg);

tv_quickReg.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

TableLayout loginForm = (TableLayout) getLayoutInflater()

.inflate(R.layout.login, null);

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

builder.setIcon(R.drawable.hat)

.setTitle("快速注册")

.setView(loginForm)

.setNegativeButton("取消", null)

.setPositiveButton("确定", null)

.create().show();

}

});

//btn_exit是退出按钮的id

Button btn_exit = findViewById(R.id.btn_exit);

btn_exit.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

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

builder.setIcon(R.drawable.alert)

.setTitle("退出?")

.setMessage("确定要退出吗?")

.setNegativeButton("取消", null)

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

@Override

public void onClick(DialogInterface dialog, int which) {

finish();

}

})

.create().show();

}

});

}

}

activity_main.xml文件:

xmlns:app="http://schemas.android.com/apk/res-auto"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".MainActivity">

android:id="@+id/linearLayout2"

android:layout_width="404dp"

android:layout_height="130dp"

android:layout_marginEnd="8dp"

android:layout_marginRight="8dp"

android:layout_marginBottom="3dp"

app:layout_constraintBottom_toTopOf="@+id/tableRow3"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent">

android:id="@+id/imageView3"

android:layout_width="156dp"

android:layout_height="match_parent"

android:layout_weight="1"

app:srcCompat="@drawable/qq" />

android:layout_width="263dp"

android:layout_height="match_parent"

android:orientation="vertical">

android:layout_width="match_parent"

android:layout_height="63dp">

android:id="@+id/textView"

android:layout_width="91dp"

android:layout_height="match_parent"

android:text="                     用户名:"

android:textColor="#E91E63"

android:textSize="20sp" />

android:id="@+id/editText"

android:layout_width="177dp"

android:layout_height="match_parent"

android:background="@drawable/editext_selector"

android:ems="10"

android:gravity="start|top"

android:hint="                                            输入用户名"

android:inputType="textMultiLine" />

android:layout_width="match_parent"

android:layout_height="63dp">

android:id="@+id/textView5"

android:layout_width="92dp"

android:layout_height="57dp"

android:text="                 密    码:"

android:textColor="#E91E63"

android:textSize="20sp" />

android:id="@+id/editText2"

android:layout_width="178dp"

android:layout_height="match_parent"

android:background="@drawable/editext_selector"

android:ems="10"

android:gravity="start|top"

android:inputType="textMultiLine" />

android:id="@+id/tableRow3"

android:layout_width="408dp"

android:layout_height="73dp"

android:layout_marginTop="3dp"

android:layout_marginEnd="4dp"

android:layout_marginRight="4dp"

app:layout_constraintBottom_toTopOf="@+id/tableRow4"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toBottomOf="@+id/linearLayout2">

android:id="@+id/checkBox"

android:layout_width="192dp"

android:layout_height="match_parent"

android:text="记住密码"

android:textSize="20sp" />

android:id="@+id/checkBox2"

android:layout_width="214dp"

android:layout_height="73dp"

android:text="自动登录"

android:textSize="20sp" />

android:id="@+id/tableRow4"

android:layout_width="410dp"

android:layout_height="44dp"

android:layout_marginEnd="2dp"

android:layout_marginRight="2dp"

app:layout_constraintBottom_toTopOf="@+id/tableRow5"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toBottomOf="@+id/tableRow3">

android:id="@+id/tv_quickReg"

android:layout_width="192dp"

android:layout_height="wrap_content"

android:text="    快速注册"

android:textColor="#009688"

android:textSize="30sp" />

android:id="@+id/textView7"

android:layout_width="217dp"

android:layout_height="wrap_content"

android:text="    忘记密码"

android:textColor="#009688"

android:textSize="30sp" />

android:id="@+id/tableRow5"

android:layout_width="409dp"

android:layout_height="63dp"

android:layout_marginEnd="3dp"

android:layout_marginRight="3dp"

android:layout_marginBottom="338dp"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toBottomOf="@+id/tableRow4">

android:id="@+id/btn_exit"

android:layout_width="192dp"

android:layout_height="match_parent"

android:text="退出"

android:textSize="30sp" />

android:id="@+id/button2"

android:layout_width="215dp"

android:layout_height="63dp"

android:text="登录"

android:textSize="30sp" />

login.xml文件:<?xml version="1.0" encoding="utf-8"?>

xmlns:app="http://schemas.android.com/apk/res-auto"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical" >

android:layout_width="400dp"

android:layout_height="102dp">

android:id="@+id/textView2"

android:layout_width="wrap_content"

android:layout_height="match_parent"

android:text="邮箱:"

android:textColor="#E91E63"

android:textSize="30sp" />

android:id="@+id/editText3"

android:layout_width="284dp"

android:layout_height="55dp"

android:background="@drawable/editext_selector"

android:ems="10"

android:gravity="start|top"

android:inputType="textMultiLine" />

android:layout_width="400dp"

android:layout_height="102dp">

android:id="@+id/textView4"

android:layout_width="127dp"

android:layout_height="match_parent"

android:text="密码:"

android:textColor="#E91E63"

android:textSize="30sp" />

android:id="@+id/editText4"

android:layout_width="284dp"

android:layout_height="55dp"

android:background="@drawable/editext_selector"

android:ems="10"

android:gravity="start|top"

android:inputType="textMultiLine" />

对话框的使用.rar

(8.58 MB, 下载次数: 0)

2020-12-18 23:14 上传

点击文件名下载附件

下载积分: 黑币 -5

安卓确定对话框java_安卓java程序 对话框的使用相关推荐

  1. 编写一个程序实现方法的覆盖java_编写Java程序代码必须先声明一个____,然后在其中编写实现需求的业务代码。...

    [多选题]下列关于多行注释的应用,正确的是( ) [单选题]是在思维中把对象分解为各个部分.侧面.属性以及阶段,分别加以考察的方法.(1.0分) [判断题]多行注释"/*...*/" ...

  2. 重启java_让Java程序自动重启的实现方法(推荐)

    要让一个java程序自动重启还真不容易的,重启分两步,首先是结束程序,这个简单,只要运行System.exit()就可以了.然后是启动,这个就难了,这个时候程序都已经结束了,就像一个人死了就不可能再自 ...

  3. 赵雅莉个人资料及年龄 java_调查:Java程序员最伤心,C++程序员最年老

    说起我们对编程世界现有的刻板印象,你一定听说过类似于没有人喜欢用Java编码或者使用C++都是老人家,等等这样的话.为了分析这些刻板印象背后的真相,Trestle Technology的数据工程师写了 ...

  4. 银联银行卡卡号java_编写Java程序,使用单例模式,创建可以生成银联借记卡号的工具类...

    编写Java程序,使用单例模式,创建可以生成银联借记卡号的工具类 编写Java程序,使用单例模式,创建可以生成银联借记卡号的工具类,银联借记卡号是一个 19 位的数字,卡号以"62" ...

  5. 字符串排序java_利用Java程序将字符串进行排序与拼接

    1.初始生成字符串的代码程序: package com.map.test; import java.util.ArrayList; import java.util.Collections; impo ...

  6. 西安华育java_成为Java程序员高手的8个条件

    该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 世界上并没有成为高手的捷径,但一些基本原则是可以遵循的.达内JavaEE培训导师,告诉你学习java有这样的素质才能成为高手! 1.扎实的基础 数据结构. ...

  7. 圆通招java_圆通java程序员面试经验|面试题 - 职朋职业圈

    面试过程: 你所写的经历项目涉及到的东西,你在项目中的职责开发了哪部分:结构体对齐相关问题,怎样避免死锁,怎样在数据库添加成员 序列化 守护进程 JAVA的垃圾回收机制然后深入探讨了下这个 I+1其他 ...

  8. excel中日期转成java_用Java程序将日期转换为序列号,就像在Excel中一样

    我已经编写了一个函数,但是它没有给出实际的O / P - public int date(Object O) { if (O instanceof Date) { Date d1 = (Date) O ...

  9. influxdb java_身为Java程序员想拿高薪?这份分布式的pdf你一定不能错过

    身为后端工程师,你对这类招聘要求肯定不陌生:熟悉分布式系统的设计和应用:熟悉分布式.缓存.消息.搜索等机制:对分布式常用技术进行合理应用.解决问题等等. 而这其中,又以分布式协议与算法尤甚.很多大公司 ...

最新文章

  1. word2013插入excel对象报错_修改Word文档中嵌入的Excel对象
  2. Android Display System --- Surface Flinger
  3. ruby语言开源Web应用框架 Ruby on Rails 简介
  4. KVM-Qemu-Libvirt三者之间的关系
  5. python【数据结构与算法】二分模板
  6. 强势回归!比 Python 快 20% 的 Pyston v2.0 来了!
  7. Google昨天发布的新产品——Google Music
  8. openfire php注册,openfire php 初始配置
  9. springboot项目实现定时任务,使用标签@Scheduled
  10. ios pan手势滑动消失动画_解析Color OS全面屏手势,操作丝滑,操作逻辑帮了大忙...
  11. 【Android】Lenovo K860 framework-res.apk回编译失败解决办法
  12. Luogu P5201 [USACO19JAN]Shortcut 最短路树???
  13. 【Windows】 rundll32.exe 在 Windows10 上的应用
  14. 基于股票大数据分析的Python入门实战(实践记录)(持续更新)
  15. 不同的count用法
  16. SPA与MPA的区别
  17. 假如小明今年第1季度的三个月中的营业额分别是{5,10,15},第二季度他计划要把第1季度中每个月的营业额都提升为2倍,请你帮小明同学计算出他第二季度的每个月营业额;
  18. python生成分析图_Pyflame 生成火焰图分析 Python 程序
  19. 基于springboot实现大学生租房系统演示【附项目源码】
  20. python中scrapy可以爬取多少数据_python scrapy框架爬取某站博人传评论数据

热门文章

  1. 图片 频率域 matlab_时间域电磁法勘探的正演问题研究
  2. 贪吃蛇c语言经典程序下载,c语言贪吃蛇源码
  3. 惠普微型计算机型号,惠普笔记本所有型号以及简介【图文】
  4. 一位男子开出的征婚条件
  5. Apache 代理(Proxy) 转发请求
  6. WEB 2.0中AJAX应用的详细探讨
  7. 移动硬盘文件或目录损坏且无法读取
  8. 工程材料(2)铁碳相图
  9. 「UG/NX」Menuscript菜单栏*.men解析
  10. Android实现录音的功能