MainActivity如下:

package cc.testsimpleactionbar0;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.app.ActionBar;
import android.app.Activity;
/**
* Demo描述:
* 显示和隐藏ActionBar,分别执行:
* mActionBar.show();
* mActionBar.hide();
* 即可
*
* 参考资料:
* Android疯狂讲义(第二版)
*/
public class MainActivity extends Activity {
private ActionBar mActionBar;
private Button mShowActionBarButton;
private Button mHideActionBarButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
init();
} private void init(){
//得到Activity的ActionBar
mActionBar=getActionBar();
mShowActionBarButton=(Button) findViewById(R.id.showActionBarButton);
mShowActionBarButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
//显示ActionBar
mActionBar.show();
}
});
mHideActionBarButton=(Button) findViewById(R.id.hideActionBarButton);
mHideActionBarButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
//隐藏ActionBar
mActionBar.hide();
}
});
}
}

main.xml如下:

<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"
android:orientation="horizontal"
> <Button
android:id="@+id/showActionBarButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="显示ActionBar"
/> <Button
android:id="@+id/hideActionBarButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="隐藏ActionBar"
/> </LinearLayout>

Android ActionBar详解(一)--->显示和隐藏ActionBar的更多相关文章

  1. Android ActionBar详解

    Android ActionBar详解 分类: Android2014-04-30 15:23 1094人阅读 评论(0) 收藏 举报 androidActionBar   目录(?)[+]   第4 ...

  2. ActionBar详解

    转: 一.ActionBar介绍 在Android 3.0中除了我们重点讲解的Fragment外,Action Bar也是一个非常重要的交互元素,Action Bar取代了传统的tittle bar和 ...

  3. 最全面的Android Webview详解

    转自:最全面的Android Webview详解 前言 现在很多App里都内置了Web网页(Hyprid App),比如说很多电商平台,淘宝.京东.聚划算等等,如下图  那么这种该如何实现呢?其实这是 ...

  4. Android Notification 详解(一)——基本操作

    Android Notification 详解(一)--基本操作 版权声明:本文为博主原创文章,未经博主允许不得转载. 微博:厉圣杰 源码:AndroidDemo/Notification 文中如有纰 ...

  5. Android Notification 详解——基本操作

    Android Notification 详解 版权声明:本文为博主原创文章,未经博主允许不得转载. 前几天项目中有用到 Android 通知相关的内容,索性把 Android Notificatio ...

  6. 6. ActionBar详解

    ActionBar简介  隐藏和显示ActionBar 隐藏ActionBar      getActionBar().hide(); 显示ActionBar      getActionBar( ...

  7. Android编译系统详解(一)

    ++++++++++++++++++++++++++++++++++++++++++ 本文系本站原创,欢迎转载! 转载请注明出处: http://blog.csdn.net/mr_raptor/art ...

  8. Android布局详解之一:FrameLayout

      原创文章,如有转载,请注明出处:http://blog.csdn.net/yihui823/article/details/6702273 FrameLayout是最简单的布局了.所有放在布局里的 ...

  9. Android菜单详解(四)——使用上下文菜单ContextMenu

    之前在<Android菜单详解(二)——创建并响应选项菜单>和<Android菜单详解(三)——SubMenu和IconMenu>中详细讲解了选项菜单,子菜单和图标菜单.今天接 ...

随机推荐

  1. Linux 学习之防火墙配置

    1.安装iptables防火墙 yum install iptables  2. 清除已有的iptables规则  iptables -F  iptables -X  iptables -Z  3.显 ...

  2. QF——iOS中的数据库操作:SQLite数据库,第三方封装库FMDB,CoreData

    SQLite数据库: SQLite是轻量级的数据库,适合应用在移动设备和小型设备上,它的优点是轻量,可移植性强.但它的缺点是它的API是用C写的,不是面向对象的.整体来说,操作起来比较麻烦.所以,一般 ...

  3. 调整 CComboBox 控件的下拉列表的高度

    CComboBox 控件的下拉列表的高度默认很小,很难看.网上查来查去终于发现如何设置. 很巧妙,要在设计视图上单击下拉列表的小箭头.这时会发现出来的边框和点其它的位置是不同的. 这个高度就是下拉列表 ...

  4. Eclipse 完全 设置UTF-8 环境

    当开始一个新的Java项目时,最好将整个环境设置为UTF-8 一般通过如下几步来设置: 1: 设置工作空间的编码格式:Window -> Preferences -> General -& ...

  5. Probability theory

    1.Probability mass functions (pmf) and Probability density functions (pdf) pmf 和 pdf 类似,但不同之处在于所适用的分 ...

  6. scala函数进阶与lazy的作用

    内容如下. lazy修饰的变量可以延迟初始化,如下面所示,文件未必存在,file变量未必有内容.

  7. CSS自学笔记(1):CSS简介

    一.什么是CSS CSS(Cascading Style Sheet(级联样式表))是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言. ...

  8. 占成本85% SSD深度选购教你如何看颗粒

    颗粒是固态硬盘负责容量和传输的介质,在这一方面上与优盘产品是相同的,从外观上看,颗粒占据了整个固态硬盘内部70%左右的空间,其同样做为成本技术,根据厂商的用料不同,成为了固态硬盘内部核心材料. 颗粒的 ...

  9. 11417 - GCD

    Problem A GCD Input: Standard Input Output: Standard Output Given the value of N, you will have to f ...

  10. MCI 函数与命令

    Microsoft 提供的 MMSYSTEM.H 文件中定义了调用 MCI 功能的数据类型和函数原型.在使用 MCI 功能的任何源模块中都应包含该文件. 1. MCI 函数 所有的 MCI 函数名都以 ...