删除对话框

 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 }

posted on 2016-05-13 22:56 那消逝的岁月 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/future-zhenzhen/p/5491448.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值