1.Dialog有四种,分别是AlertDialog,ProgressDialog,DatePickerDialog,TimePickerDialog

1.1AlertDialog

public class MainActivity extends Activity {
private View view;
private TextView tView;
private EditText eText; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
LayoutInflater layoutInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
view = layoutInflater.inflate(R.layout.cell, null);
tView = (TextView) view.findViewById(R.id.tv2);
eText = (EditText) view.findViewById(R.id.et1);
new AlertDialog.Builder(this).setTitle("友情提示").setView(view)
.setMessage("确定退出?")
.setNegativeButton("取消", new OnClickListener() { @Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Toast.makeText(MainActivity.this, "确定",
Toast.LENGTH_SHORT).show();
}
}).setNeutralButton("中立", new OnClickListener() { @Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Toast.makeText(MainActivity.this, "取消",
Toast.LENGTH_SHORT).show();
}
}).setPositiveButton("确定", new OnClickListener() { @Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Toast.makeText(MainActivity.this, eText.getText()
.toString(), Toast.LENGTH_SHORT).show();
// tView.setText(eText.getText().toString());
}
}).show();
} }

1.2ProgressDialog

	ProgressDialog pgd = new ProgressDialog(this);
pgd.setTitle("nihao");
pgd.setMessage("hehe");
//pgd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
pgd.setProgress(100);
pgd.show();

1.3DatePickerDialog

DatePickerDialog datePickerDialog = new DatePickerDialog(this,new OnDateSetListener() {

		@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
// TODO Auto-generated method stub }
}, myear,mmouth,mday);datePickerDialog.show();

1.4 TimePickerDialog

于1.3相同的使用方式。

2.Menu有三种:分别是:optionsMenu,SubMenu,ContextMenu

2.1.OptionsMenu

public boolean onCreateOptionsMenu(Menu menu) {
menu.add(menu.NONE,1,menu.NONE,"菜单1");
menu.add(menu.NONE,2,menu.NONE,"菜单2");
menu.add(menu.NONE,3,menu.NONE,"菜单3");
menu.add(menu.NONE,4,menu.NONE,"菜单4");
menu.add(menu.NONE,5,menu.NONE,"菜单5");
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case 1:
Toast.makeText(this,"1", Toast.LENGTH_SHORT).show();
break; default:
Toast.makeText(this,"其他", Toast.LENGTH_SHORT).show();
break;
}
return super.onOptionsItemSelected(item);
}

2.2.SubMenu

@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(menu.NONE,1,menu.NONE,"菜单1");
menu.add(menu.NONE,2,menu.NONE,"菜单2");
menu.add(menu.NONE,3,menu.NONE,"菜单3");
menu.add(menu.NONE,4,menu.NONE,"菜单4");
menu.add(menu.NONE,5,menu.NONE,"菜单5");
SubMenu subMenu = menu.addSubMenu(menu.NONE,6,menu.NONE,"菜单6");
subMenu.setHeaderTitle("你好");
subMenu.setIcon(R.drawable.ic_launcher);
subMenu.addSubMenu(menu.NONE,7,menu.NONE,"菜单7");
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case 1:
Toast.makeText(this,"1", Toast.LENGTH_SHORT).show();
break; default:
Toast.makeText(this,"其他", Toast.LENGTH_SHORT).show();
break;
}
return super.onOptionsItemSelected(item);
}

2.3ContextMenu

public class MainActivity extends Activity {

	@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); TextView textView = (TextView) findViewById(R.id.tv1);
registerForContextMenu(textView);
} @Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
menu.add(menu.NONE,1,menu.NONE,"菜单1");
menu.add(menu.NONE,2,menu.NONE,"菜单2");
menu.add(menu.NONE,3,menu.NONE,"菜单3");
menu.add(menu.NONE,4,menu.NONE,"菜单4");
menu.add(menu.NONE,5,menu.NONE,"菜单5");
super.onCreateContextMenu(menu, v, menuInfo);
}
@Override
public boolean onContextItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch (item.getItemId()) {
case 1:
Toast.makeText(this,"1",Toast.LENGTH_SHORT).show();
break; default:
break;
}
return super.onContextItemSelected(item);
}
}

3.Notification

NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
//声明Notification
Notification notification = new Notification();
//设置notification的参数
notification.icon=R.drawable.ic_launcher; Intent intent = new Intent(this,MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this,0, intent,0);
notification.setLatestEventInfo(this,"haha" ,"contentText",pendingIntent);
notificationManager.notify(10,notification);

4.TabHost

TabHost tabHost = getTabHost();
LayoutInflater.from(this).inflate(R.layout.activity_main,
tabHost.getTabContentView(), true);
Intent intent = new Intent(MainActivity.this, SeocndActivity.class); tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("搜索")
.setContent(intent));
tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("搜索")
.setContent(intent));
tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("搜索")
.setContent(R.id.l1));

007.androidUI开发进阶(基础--案例) .的更多相关文章

  1. mysql 开发进阶篇系列 46 物理备份与恢复( xtrabackup的 选项说明,增加备份用户,完全备份案例)

    一. xtrabackup 选项说明 在操作xtrabackup备份与恢复之前,先看下该工具的选项,下面记录了xtrabackup二进制文件的部分命令行选项,后期把常用的选项在补上.点击查看xtrab ...

  2. TypeScript进阶开发——ThreeJs基础实例,从入坑到入门

    前言 我们前面使用的是自己编写的ts,以及自己手动引入的jquery,由于第三方库采用的是直接引入js,没有d.ts声明文件,开发起来很累,所以一般情况下我们使用npm引入第三方的库,本文记录使用np ...

  3. 处女作《Web全栈开发进阶之路》出版了!

    书中源码下载地址:https://github.com/qinggee/WebAdvanced 01. 当初决定写博客的原因非常的纯洁:只要每个月写上 4 篇以上博客,月底的绩效奖金就多 500 块. ...

  4. [转]抢先Mark!微信公众平台开发进阶篇资源集锦

    FROM : http://www.csdn.net/article/2014-08-01/2820986 由CSDN和<程序员>杂志联合主办的 2014年微信开发者大会 将于8月23日在 ...

  5. WEB前端开发CSS基础样式全面总结

    Web前端开发css基础样式全面总结 颜色和单位的使用 颜色 用颜色的名字表示颜色,比如:red 用16进制表示演示 比如:#FF0000 用rgb数值表示颜色,rgb(红,绿,蓝),每个值都在0-2 ...

  6. iOS开发进阶

    <iOS开发进阶>基本信息作者: 唐巧 出版社:电子工业出版社ISBN:9787121247453上架时间:2014-12-26出版日期:2015 年1月开本:16开页码:268版次:1- ...

  7. HTML5游戏开发进阶指南(亚马逊5星畅销书,教你用HTML5和JavaScript构建游戏!)

    HTML5游戏开发进阶指南(亚马逊星畅销书,教你用HTML5和JavaScript构建游戏!) [印]香卡(Shankar,A.R.)著 谢光磊译 ISBN 978-7-121-21226-0 201 ...

  8. iOS原生地图开发进阶——使用导航和附近兴趣点检索

    iOS原生地图开发进阶——使用导航和附近兴趣点检索 iOS中的mapKit框架对国际化的支持非常出色.在前些篇博客中,对这个地图框架的基础用法和标注与覆盖物的添加进行了详细的介绍,这篇博客将介绍两个更 ...

  9. HTML5游戏开发进阶指南

    <HTML5游戏开发进阶指南> 基本信息 作者: (印)香卡(Shankar,A.R.)    译者: 谢光磊 出版社:电子工业出版社 ISBN:9787121212260 上架时间:20 ...

随机推荐

  1. This application failed to start because it could not find or load the Qt platform plugin "windows"

    发生以上错误的Qt版本应该是Qt 5.0.0以上的版本吧. 出现标题错误的大致原因是:因为Qt是跨平台的库,需要依赖于相关的平台库.有个Platform的文件夹,里面有相关dll文件. referen ...

  2. logstash 防止实际处理时间跟事件产生时间略有偏差

    "message" => " 10.168.255.134 [12/Sep/2016:16:30:40 +0800] \"GET /resources/p ...

  3. bzoj1734 [Usaco2005 feb]Aggressive cows 愤怒的牛

    Description Farmer John has built a new long barn, with N (2 <= N <= 100,000) stalls. The stal ...

  4. boost格式化输出xml

    我的boost为1.56而不是1.55 boost在xml的例子给出了一段写xml文件的代码,我简化如下: void debug_settings::save(const std::string &a ...

  5. PHP设计模式笔记一:准备工作 -- Rango韩老师 http://www.imooc.com/learn/236

    一.编程字体选择 1.选择等宽字体 包括Courier New ,Consolas,Source Code Pro(推荐) 2.环境搭建(建议easyPHP) 二.开发符合PSR规范的基础框架 PSR ...

  6. JBoss AS 7性能调优(三)

    原文:http://www.mastertheboss.com/jboss-performance/jboss-as-7-performance-tuning/page-4 调优Webserver线程 ...

  7. Android应用程序内部启动Activity过程(startActivity)的源代码分析

    文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/6703247 上文介绍了Android应用程序的 ...

  8. ORA-00119: invalid specification for system parameter LOCAL_LISTENER

    重启oracle是提示错误ORA-00119: invalid specification for system parameter LOCAL_LISTENER. 解决方法: 命令查看错误信息:oe ...

  9. C#中的一种按日期分文件夹的日志写法

    众所周知,日志是调试程序的有效途径,有一个好的日志代码,是一个程序小猿梦寐以求的. 以下是我结合网上资源自己总结的一小段代码,请笑纳: 转载请注明来源: http://www.cnblogs.com/ ...

  10. MySql命令——命令行客户机的分隔符

    delimiter // create procedure productpricint() begin select avg(price) as priceaverage from product; ...