ackage com.example.helloworld;

import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.view.Menu;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Button btn=(Button)this.findViewById(R.id.button1);
btn.setOnClickListener( new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Dialog myDialog= new AlertDialog.Builder(MainActivity.this).setTitle("标题").setMessage("提示").create();
myDialog.show();

}
});
}

@Override
public 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;
}

}

Android 按钮 弹出对话框的更多相关文章

  1. Android 使用弹出对话框,报Unable to add window错误

    今天在使用Android弹出对话框的时候,报了一个unable to add window错误,我的代码如下 new AlertDialog.Builder(getApplicationContext ...

  2. ExtJs 4.2.1 点击按钮弹出表单的窗口

    初学ExtJs,做项目的时候想做一个这样的效果:点击按钮弹出对话框,之前一直是使用EasyUi来做的, EasyUi里有Dialog,用起来很方便,但是现在转移到ExtJs上后,发现没有Dialog这 ...

  3. Android 手机卫士--弹出对话框

    在<Android 手机卫士--解析json与消息机制发送不同类型消息>一文中,消息机制发送不同类型的信息还没有完全实现,在出现异常的时候,应该弹出吐司提示异常,代码如下: private ...

  4. UI设计, 弹出对话框 设计(区分强调按钮和普通按钮,给用户一个 正向建议的强调按钮)

    在UI设计时,经常会需要 设计 弹出对话框,以下是个样式设计: 0.标准对话框 说明 Title space : 标题区 contents space : 内容区 function space: 功能 ...

  5. 确认(confirm 消息对话框)语法:confirm(str); 消息对话框通常用于允许用户做选择的动作,如:“你对吗?”等。弹出对话框(包括一个确定按钮和一个取消按钮)

    确认(confirm 消息对话框) confirm 消息对话框通常用于允许用户做选择的动作,如:"你对吗?"等.弹出对话框(包括一个确定按钮和一个取消按钮). 语法: confir ...

  6. CGridCtrl只点击规定行中的按钮才弹出对话框

    在头文件中添加: afx_msg void OnClick(NMHDR* pNMHDR, LRESULT* pResult); 添加映射:ON_NOTIFY(NM_CLICK, IDC_CUSTOM1 ...

  7. AlertDialog.Builder弹出对话框

    在Android中,弹出对话框使用AlertDialog.Builder方法. new AlertDialog.Builder(MainActivity.this).setTitle("本机 ...

  8. 安卓弹出对话框——Alertdialog

    在Android开发当中,在界面上弹出一个Dialog对话框使我们经常需要做的,本篇随笔将详细的讲解Dialog对话框这个概念,包括定义不同样式的对话框. 一.Dialog 我们首先来看看androi ...

  9. 安卓弹出对话框——Alertdialog(一)

    首先看各种样式的对话框: 我们看到,Dialog有很多的子类实现,所以我们要定义一个对话框,使用其子类来实例化一个即可,而不要直接使用Dialog这个父类来构造. 二.AlertDialog 今天我们 ...

随机推荐

  1. 【BZOJ】1668: [Usaco2006 Oct]Cow Pie Treasures 馅饼里的财富(dp)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1668 裸dp.. f[i][j]表示i行j列最大能拿到 f[i][j]=max(f[i+1][j-1 ...

  2. C# 将MSMQ消息转换成Json格式

    PS:主要就是一个配置文件和一个转换函数 配置文件app.config  之前要ADD reference -->   system.configuration & using.syst ...

  3. 如何用几何画板画V型尖波函数图像

    虽然几何画板没有编程功能,无法直接进行逻辑判断,但通过恰当地运用sgn.trunc等函数可以间接地画出一些特殊函数图像,比如V型尖波函数图像,下面将详细介绍如何用几何画板画V型尖波函数图像. 具体的操 ...

  4. Hadoop单机安装配置过程:

    1. 首先安装JDK,必须是sun公司的jdk,最好1.6版本以上. 最后java –version 查看成功与否. 注意配置/etc/profile文件,在其后面加上下面几句: export JAV ...

  5. FragmentStatePagerAdapter写法

    为了节省资源,分批加载数据//适配器class TabLayoutViewPagerAdapter extends FragmentStatePagerAdapter { public TabLayo ...

  6. java面向对象基础回顾

    (49)  (0) 面向对象 啥是面向对象 什么是多态多态的机制 接口和抽象类区别 个人理解 代码实现 面向对象 学习java大家接触到的最多的话语无非就是面向对象,可能大家没有仔细研究过这个问题,但 ...

  7. dao---service---action分层结构

    此文转载于http://blog.csdn.net/jay198746/article/details/4698709 之前有看过一些ssh2中采用dao---service---action分层结构 ...

  8. ZOJ 3932 Deque and Balls

    There are n balls, where the i-th ball is labeled as pi. You are going to put n balls into a deque. ...

  9. window.location下的属性说明

    属性 说明 window.location.href 完整的url window.location.protocol 协议 window.location.hostname 主机名 window.lo ...

  10. HDU_5512_Pagodas

    Pagodas Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Sub ...