显示提示消息的对话框
来源:互联网 发布:利艾r18漫画艾伦性淘宝 编辑:程序博客网 时间:2024/04/28 15:06
页面布局中只有一个简单的文本框和一个按钮。
dialog.xml:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <EditText android:id="@+id/show" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" > </EditText> <Button android:id="@+id/bn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /></LinearLayout>
Dialog.java
package org.helloword;import android.app.Activity;import android.app.AlertDialog;import android.app.AlertDialog.Builder;import android.content.DialogInterface;import android.content.DialogInterface.OnClickListener;import android.os.Build;import android.os.Bundle;import android.view.LayoutInflater;import android.view.View;import android.widget.Button;import android.widget.EditText;import android.widget.TabHost;public class Dialog extends Activity{@Overridepublic void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.dialog);Button bn=(Button)findViewById(R.id.bn);final Builder builder=new AlertDialog.Builder(this);//为按钮绑定事件监听器bn.setOnClickListener(new View.OnClickListener() {public void onClick(View source) {// TODO Auto-generated method stubbuilder.setIcon(R.drawable.bg_border);builder.setTitle("自定义普通对话框");builder.setMessage("一个简单的提示对话框");//为对话框设置一个“确定”按钮builder.setPositiveButton("确定", new OnClickListener(){public void onClick(DialogInterface dialog,int which){EditText show=(EditText)findViewById(R.id.show);show.setText("用户单击了“确定”按钮!");}});//为对话框设置一个“取消”按钮builder.setNegativeButton("取消",new OnClickListener(){public void onClick(DialogInterface dialog,int which){EditText show=(EditText)findViewById(R.id.show);show.setText("用户单击了“取消”按钮!");}});//创建并显示对话框builder.create().show();}});}}
- 显示提示消息的对话框
- 显示消息提示对话框--封装类
- JS显示消息提示对话框公共类
- 使用AlertDialog创建简单的对话框1-显示提示消息的对话框
- Android AlertDialog对话框的使用及实例(显示提示消息的对话框)
- asp.net显示消息提示对话框,并进行页面跳转
- 显示消息提示对话框,关闭当前窗口,刷新父窗口
- Eclipse JFace 对话框显示中文(弹出消息提示框)
- pygtk消息提示对话框
- 【Android开发】消息提示框与对话框-使用Toast显示消息提示框
- PB中消息对话框的居中显示
- PB中消息对话框的居中显示
- SWT 消息提示框 对话框
- 消息提示框和对话框
- Android消息提示框和对话框的使用
- cocos2dx 消息提示显示
- Delphi 显示提示消息
- 显示消息提示对话框,不输出页面内容,并返回上一页
- 单片机之旅——1
- oracle 约束
- ssh HibernateDaoSupport spring 事务配置说明
- 通过2个实例理解:不要返回指向栈内存的指针
- 单片机之旅——中断之流水灯
- 显示提示消息的对话框
- codeforces Round # 187(Div.2) D
- Java请求远程URL
- OpenStack对象存储管理手册(4) OpenStack对象存储系统管理-2
- boost——字符串与数字的转换
- Android Animation学习笔记
- 标准化与先进生产力
- Tomcat研究之组件结构
- 单片机之旅——串口、8*8点阵