AndroidUI组件之ActionBar
有一段时间没有写博文了,发现自己的博文的完整度不是非常好。就拿AndroidUI组件这一块。一直没有更新完。我会尽快更新。好了。不多说了,今天来看一下ActionBar。
依照以往的作风。知识点都以代码凝视的形式在源码中。
package com.gc.actionbardemo;
/**
* 1、活动条(ActionBar)是Android3.0的重要更新之中的一个。 ActionBar位于传统标题栏的位置
* 也就是显示的屏幕的顶部。ActionBar可显示应用的图标和Activity标题---也就是应用
* 程序顶部显示的内容。除此之外。ActionBar的右边还能够显示活动项。
* 2、ActionBar提供了例如以下功能
* (1)显示选项菜单的菜单项(将菜单项显示成Action Item)
* (2)使用程序图标作为返回Home主屏或向上的导航操作
* (3)提供交互式View作为Action View
* (4)提供基于Tab的导航方式,可用于切换多个Fragment
* (5)提供基于下拉的导航方式
* 3、假设希望关闭ActionBar。能够设置该应用的主题为Xxx.NoActionBar
* 4、一旦关闭了ActionBar。该Android应用将不能使用ActionBar
* 5、实际项目中。通常推荐使用代码来控制ActionBar显示、隐藏,ActionBar
* 提供了例如以下方法来控制显示、隐藏。
* show():显示ActionBar
* hide():隐藏ActionBar
*/
import android.os.Bundle;
import android.app.ActionBar;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
/**
*
* @author Android将军
*
*/
public class ActionBarTest extends Activity { private ActionBar actionBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_action_bar_test);
//获取该Activity的ActionBar
//仅仅有当应用主题没有关闭ActionBar时,该代码才干返回ActionBar
actionBar=getActionBar();
}
//为“显示ActionBar”button定义事件处理方法
public void showActionBar(View source)
{
//显示ActionBar
actionBar.show();
}
//为“隐藏ActionBar”button定义事件处理方法
public void hideActionBar(View source)
{
//隐藏ActionBar
actionBar.hide();
} }
该Activity所相应的布局文件是activity_action_bar_test,代码例如以下所看到的:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
> <Button
android:onClick="showActionBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="显示ActionBar" />
<Button
android:onClick="hideActionBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="隐藏ActionBar" /> </LinearLayout>
效果演演示样例如以下:
转载请注明出处:http://blog.csdn.net/android_jiangjun/article/details/38230733
AndroidUI组件之ActionBar的更多相关文章
- AndroidUI组件之ImageSwitcher
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/gc_gongchao/article/details/25594669 今天继续AndroidUI组 ...
- AndroidUI组件之ActionBar--基于下拉的导航方式
在上一篇关于ActionBar的博文中.我们知道了ActionBar是Android3.0的重要更新之中的一个.本篇博文就来写一个开发中经经常使用到的样例.用ActionBar提供基于下拉的导航方 ...
- android-UI组件实例大全(六)------ImageView图像视图
图像视图:ImageView 继承view类,用于在屏幕上显示任何Drawable对象,通常用来显示图片: 这里的话我们介绍一些比较常用的属性: Path 1: android:adjustViewB ...
- AndroidUI组件之TabHost
package com.gc.tabhost; /** * @author Android将军 * * * * 1.TabHost是一种非常有用的组件,TabHost能够非常方便地在窗体上放置 * 多 ...
- android-UI组件(四):AdapterView及其子类
http://blog.csdn.net/litianpenghaha/article/details/23270881 AdapterView组件是一组重要的组件,AdapterView本身是一个抽 ...
- AndroidUI组件之AdapterViewFilpper
package com.gc.adapterviewflipperdemo; /** * 功能:自己主动播放的图片库 * @author Android将军 */ /* * 1.AdapterView ...
- AndroidUI组件之ListView小技巧
android:fadingEdge="none"//出去黑影 android:listSelector="@android:color/transparent&quo ...
- 第九章 Android-UI组件(2)
一.图像视图(ImageView) 布局 <?xml version="1.0" encoding="utf-8"?> <LinearLayo ...
- 第七章 android-UI组件
一.本章目录 二.用户界面概述 1,用户界面简介 (1)系统和用户之间进行信息交换的媒介 2,设计手机用户界面应解决的问题 (1)需要界面设计和逻辑代码完全分离(布局和逻辑代码分开放) (2)根据不同 ...
随机推荐
- Ambari是啥?主要是干啥的?
简单来说,Ambari是一个拥有集群自动化安装.中心化管理.集群监控.报警功能的一个工具(软件),使得安装集群从几天的时间缩短在几个小时内,运维人员从数十人降低到几人以内,极大的提高集群管理的效率. ...
- C语言常量
Constant包括4种类型: 整型 浮点型 枚举 字符型 #include <stddef.h> #include <uchar.h> int main() { /* Int ...
- 关闭掉eclipse启动的自动更新功能(提高打开eclipse的速度)
- k[原创]Faster R-CNN论文翻译
物体检测论文翻译系列: 建议从前往后看,这些论文之间具有明显的延续性和递进性. R-CNN SPP-net Fast R-CNN Faster R-CNN Faster R-CNN论文翻译 原文地 ...
- java实例1
1.满天星星 import java.awt.*; public class xinxin { public static void main(String[] args) { Frame w = n ...
- 视频cover占满
/* 关键属性 */ object-fit: fill; //被替换的内容的大小,以填补该元素的内容框:对象的具体对象的大小是元素的使用宽度和高度. object-fit: contain;被替换的内 ...
- (2)搜索广告CTR预估
https://www.cnblogs.com/futurehau/p/6184585.html 1. CTR预估的流程 数据 -> 预处理 ->特征抽取 ->模型训练 ->后 ...
- Python学习【第7篇】:Python之常用模块2
hashlib,configparser,logging模块 一.常用模块二 hashlib模块 hashlib提供了常见的摘要算法,如md5和sha1等等. 那么什么是摘要算法呢?摘要算法又称为哈希 ...
- 学习MPI并行编程记录
简单的MPI程序示例 首先,我们来看一个简单的MPI程序实例.如同我们学习各种语言的第一个程序一样,对于MPI的第一个程序同样是"Hello Word". /* Case 1 he ...
- 网络编程:tcp、udp、socket、struct、socketserver
一.TCP.UDP 一.ARP(Address Resolution Protocol)即地址解析协议,用于实现从 IP 地址到 MAC 地址的映射,即询问目标IP对应的MAC地址. 二.在网络通信中 ...