Android之警告对话框alertdialog
来源:互联网 发布:word2010数据透视表 编辑:程序博客网 时间:2024/04/27 23:39
package com.example.android_alertdialog;import android.support.v7.app.ActionBarActivity;import android.app.AlertDialog;import android.content.DialogInterface;import android.os.Bundle;import android.view.Menu;import android.view.MenuItem;import android.view.View;import android.widget.Button;import android.widget.Toast;public class MainActivity extends ActionBarActivity {private Button btn;private AlertDialog.Builder builder;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);btn=(Button) this.findViewById(R.id.button1);builder=new AlertDialog.Builder(this);//构建警告对话框builder.setTitle("提示框");builder.setMessage("您确定要删除吗?");builder.setIcon(R.drawable.ic_launcher);//加个小机器人图标builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int which) {// TODO Auto-generated method stubToast.makeText(MainActivity.this, "确定删除!", 1).show();}});builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int which) {// TODO Auto-generated method stubToast.makeText(MainActivity.this, "取消删除!", 1).show();}});builder.setNeutralButton("忽略", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int which) {// TODO Auto-generated method stubToast.makeText(MainActivity.this, "忽略删除!", 1).show();}});btn.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stubbuilder.show();//点击的时候对话框弹出来}});}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.main, menu);return true;}@Overridepublic boolean onOptionsItemSelected(MenuItem item) {// Handle action bar item clicks here. The action bar will// automatically handle clicks on the Home/Up button, so long// as you specify a parent activity in AndroidManifest.xml.int id = item.getItemId();if (id == R.id.action_settings) {return true;}return super.onOptionsItemSelected(item);}}
运行效果图如下
0 0
- Android之警告对话框alertdialog
- Android用户界面对话框之警告对话框(ALertDialog)
- Android用户界面对话框之警告对话框(ALertDialog)
- Android AlertDialog警告对话框实现
- Android对话框之AlertDialog
- android之AlertDialog对话框
- Android之AlertDialog对话框
- AlertDialog 警告对话框
- AlertDialog 警告对话框
- Android之AlertDialog自定义对话框
- android 对话框之AlertDialog&ProgressDialog
- Android中的警告对话框(AlertDialog)使用案例
- Android中的AlertDialog使用示例一(警告对话框)
- 警告对话框AlertDialog的使用
- Android--AlertDialog--警告框
- Android 对话框 之AlertDialog和Dialog
- android 弹出对话框之 AlertDialog
- Android控件之AlertDialog-自定义对话框
- 正益工场:技术&生态共进,加速企业“电商O2O”转型
- 不通过App Store,在iOS设备上直接安装应用程序
- 用PHP实现简单的IoC控制反转(DI依赖注入模式)
- jsp中怎么判断密码中不能含有空格,帐号只能由字母、数字、汉字、下划线“_”组成
- android转eclipse
- Android之警告对话框alertdialog
- css中filter:alpha透明度使用小结兼容IE、火狐
- PHP5魔术函数与魔术常量
- myeclipes 看源代码解决
- Unix Shell中用[-n]判断字符串不为NULL
- opencv中的矩阵操作
- 查看图片列表,选中之后查看大图,可缩放滑动
- CUICatalog: Invalid asset name supplied: (null), or invalid scale factor:2.000000
- python实现哈夫曼编码