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;
}

}

更多相关文章

  1. Android(安卓)代码片段---从相册或相机获取图片保存并处理
  2. Android(安卓)复用自制的控件(2)
  3. android 弹出带按钮的对话框
  4. Android标题栏(titlebar)显示进度条
  5. android 如何去掉状态栏和标题栏
  6. Android(安卓)TV自定义通用标题栏(组合控件)
  7. android Multiple markers at this line - The type java.lang.C
  8. 【Android学习笔记】AutoCompleteTextView(数组在代码中)
  9. Android(安卓)Studio自带模拟器读写SDcard不成功的解决办法

随机推荐

  1. android makefile(android.mk)分析(序)
  2. Android进程管理简单介绍
  3. 最新的免费android教程,助你深入浅出的轻
  4. Android自定义属性与自定义属性的获取
  5. Android壁纸机制(Android Q与老版本对比)
  6. Android中AsyncTask详解,源码剖析(API 23)
  7. Android获取机身存储、内置SD卡与外置TF
  8. 制约Android发展的三大难题
  9. Android 4.0应用界面设计分析
  10. Android Handler 线程消息机制