Android中的AlertDialog使用示例一(警告对话框)

Linux大全评论439 views阅读模式

在Android开发中,我们经常会需要在Android界面上弹出一些对话框,比如询问用户或者让用户选择。这些功能我们叫它Android Dialog对话框,AlertDialog实现方法为建造者模式。下面我们模拟卸载应用程序时弹出的最为普通的警告对话框,如下图:

Android中的AlertDialog使用示例一(警告对话框)

layout布局界面代码示例:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <Button
        android:text="卸载"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:onClick="show"
        android:id="@+id/button" />
</LinearLayout>

Java实现代码:

企鹅博客
  • 本文由 发表于 2019年9月24日 17:18:32
  • 转载请务必保留本文链接:https://www.qieseo.com/134855.html

发表评论