Android应用开发笔记 - 项目代码3
来源:互联网 发布:淘宝dnf游戏币 编辑:程序博客网 时间:2024/06/16 22:42
1.3 App类控件
MainActivity.java
package com.example.apppalettesdemo;import android.os.Bundle;import android.app.Activity;import android.app.AlertDialog;import android.app.AlertDialog.Builder;import android.app.Notification;import android.app.NotificationManager;import android.app.PendingIntent;import android.app.ProgressDialog;import android.content.DialogInterface;import android.content.DialogInterface.OnClickListener;import android.content.Intent;import android.view.Menu;import android.view.MenuItem;import android.widget.Toast;public class MainActivity extends Activity implements OnClickListener { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.my_options_menu, menu); return true; } @Overridepublic boolean onOptionsItemSelected(MenuItem item) {// TODO Auto-generated method stub Boolean flag = false; switch (item.getItemId()) {case R.id.AlertDialog01:Builder dialog = new AlertDialog.Builder(MainActivity.this);dialog.setTitle("Hint");dialog.setMessage("This is Message!");dialog.setPositiveButton("Ok", this);dialog.show();flag = true;break;case R.id.notificationManager01:NotificationManager notiManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);Notification notiInst = new Notification(R.drawable.ic_launcher, "This is notify 2012-09-12", System.currentTimeMillis());PendingIntent pendIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);notiInst.setLatestEventInfo(this, "Notify", "Notify 01", pendIntent);notiManager.notify(0, notiInst);flag = true;break;case R.id.progressDialog01:ProgressDialog progrDialog = new ProgressDialog(this);progrDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);progrDialog.setMessage("Loading Information...");progrDialog.show();flag = true;break;default:break;}return flag;} // DialogInterface @Overridepublic void onClick(DialogInterface dialog, int which) {// TODO Auto-generated method stubToast.makeText(this, "You just press 'AlertDialog' button!", Toast.LENGTH_SHORT).show();} }
---------------xiaobin-author--
- Android应用开发笔记 - 项目代码3
- Android应用开发笔记 - 项目代码1
- Android应用开发笔记 - 项目代码2
- Android笔记---- Android应用界面开发(3)
- Android应用开发笔记
- Android应用开发笔记
- android应用开发笔记
- Android项目开发笔记
- android应用开发代码规范
- android应用开发笔记---Activity
- Android 应用开发笔记 - Preface
- Android应用开发学习笔记
- Android 应用界面开发笔记
- android项目开发笔记HierarchyViewer
- Android 应用开发笔记 - 应用程序设计基础
- android应用开发学习笔记--游戏开发
- Android 应用开发笔记 - UI开发详解
- 学习笔记之《Android应用案例开发大全》(全部调试过代码)
- poj 1470 Closest Common Ancestors
- Mac os 10.7.5 bash 问题。郁闷至极
- HDU-4193 Non-negative Partial Sums 单调队列
- js正则表达式限制文本框只能输入数字,小数点,英文字母
- Android工程gen目录无法生成的解决办法汇总
- Android应用开发笔记 - 项目代码3
- struts2学习第三天----struts.xml文件导入其他的.xml文件
- Hibernate--可持久化对象
- Qt 5中元对象系统的改变
- 题目14:最小的K个数
- JBOSS JSP页面修改后要重新启动JBOSS才能重新部署上去 eclipse下 不同步
- linux内核学习之网络篇——网络物理层的设备初步
- CGLIB实现动态代理
- 国内顶级IT公司面试题