zoukankan      html  css  js  c++  java
  • 删除对话框

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     3     xmlns:tools="http://schemas.android.com/tools"
     4     android:layout_width="match_parent"
     5     android:layout_height="match_parent"
     6     android:paddingBottom="@dimen/activity_vertical_margin"
     7     android:paddingLeft="@dimen/activity_horizontal_margin"
     8     android:paddingRight="@dimen/activity_horizontal_margin"
     9     android:paddingTop="@dimen/activity_vertical_margin"
    10     tools:context="com.hanqi.testapp2.Zuoye">
    11 
    12     <Button
    13         android:layout_width="match_parent"
    14         android:layout_height="wrap_content"
    15         android:text="删除"
    16         android:onClick="bt1_OnClick"/>
    17 
    18 </RelativeLayout>
     1 <?xml version="1.0" encoding="utf-8"?>
     2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     3     android:orientation="vertical"
     4     android:layout_width="match_parent"
     5     android:layout_height="match_parent">
     6 
     7     <TextView
     8         android:layout_height="wrap_content"
     9         android:text="确定要删除吗?"
    10         android:layout_width="wrap_content" />
    11     <TextView
    12         android:layout_height="wrap_content"
    13         android:text="要删除,请点击“是”。"
    14         android:layout_width="wrap_content" />
    15 
    16 </LinearLayout>
     1 package com.hanqi.testapp2;
     2 
     3 import android.app.AlertDialog;
     4 import android.content.DialogInterface;
     5 import android.os.Bundle;
     6 import android.support.v7.app.AppCompatActivity;
     7 import android.view.View;
     8 import android.widget.Toast;
     9 
    10 public class Zuoye extends AppCompatActivity {
    11 
    12     @Override
    13     protected void onCreate(Bundle savedInstanceState) {
    14         super.onCreate(savedInstanceState);
    15         setContentView(R.layout.activity_zuoye);
    16     }
    17 
    18     public void bt1_OnClick(View v)
    19     {
    20         //View view = View.inflate(this, R.layout.shanchu, null);
    21 
    22         new AlertDialog.Builder(this)
    23                 .setTitle("提示")
    24                 .setView(R.layout.shanchu)
    25                 .setPositiveButton("是", new DialogInterface.OnClickListener() {
    26                     @Override
    27                     public void onClick(DialogInterface dialog, int which) {
    28                         Toast.makeText(Zuoye.this, "执行删除", Toast.LENGTH_SHORT).show();
    29                     }
    30                 })
    31                 .setNegativeButton("否",null)
    32                 .setCancelable(false)
    33                 .show();
    34     }
    35 }

  • 相关阅读:
    MVC3.0 如何点击点击一张图片连接到另一地址
    什么是SMTP?
    ASP.NET MVC中 Jquery AJAX 获取数据利用MVC模型绑定实现输出
    MVC HTML控件扩展例子
    连接局域网内的mysql服务
    python loger 模板
    培养正确的编程态度和方法转
    Chrome不支持showModalDialog模态对话框和无法返回returnValue的问题
    SQL中时间与秒互转
    VS开发好用的扩展
  • 原文地址:https://www.cnblogs.com/future-zhenzhen/p/5491448.html
Copyright © 2011-2022 走看看