码迷,mamicode.com
首页 > 其他好文 > 详细

删除对话框

时间:2016-05-13 23:23:05      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:

 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 }

技术分享

删除对话框

标签:

原文地址:http://www.cnblogs.com/future-zhenzhen/p/5491448.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!