Android ActionBar详解(一)--->显示和隐藏ActionBar
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的更多相关文章
- Android ActionBar详解
Android ActionBar详解 分类: Android2014-04-30 15:23 1094人阅读 评论(0) 收藏 举报 androidActionBar 目录(?)[+] 第4 ...
- ActionBar详解
转: 一.ActionBar介绍 在Android 3.0中除了我们重点讲解的Fragment外,Action Bar也是一个非常重要的交互元素,Action Bar取代了传统的tittle bar和 ...
- 最全面的Android Webview详解
转自:最全面的Android Webview详解 前言 现在很多App里都内置了Web网页(Hyprid App),比如说很多电商平台,淘宝.京东.聚划算等等,如下图 那么这种该如何实现呢?其实这是 ...
- Android Notification 详解(一)——基本操作
Android Notification 详解(一)--基本操作 版权声明:本文为博主原创文章,未经博主允许不得转载. 微博:厉圣杰 源码:AndroidDemo/Notification 文中如有纰 ...
- Android Notification 详解——基本操作
Android Notification 详解 版权声明:本文为博主原创文章,未经博主允许不得转载. 前几天项目中有用到 Android 通知相关的内容,索性把 Android Notificatio ...
- 6. ActionBar详解
ActionBar简介 隐藏和显示ActionBar 隐藏ActionBar getActionBar().hide(); 显示ActionBar getActionBar( ...
- Android编译系统详解(一)
++++++++++++++++++++++++++++++++++++++++++ 本文系本站原创,欢迎转载! 转载请注明出处: http://blog.csdn.net/mr_raptor/art ...
- Android布局详解之一:FrameLayout
原创文章,如有转载,请注明出处:http://blog.csdn.net/yihui823/article/details/6702273 FrameLayout是最简单的布局了.所有放在布局里的 ...
- Android菜单详解(四)——使用上下文菜单ContextMenu
之前在<Android菜单详解(二)——创建并响应选项菜单>和<Android菜单详解(三)——SubMenu和IconMenu>中详细讲解了选项菜单,子菜单和图标菜单.今天接 ...
随机推荐
- 黑马程序员 Java基础<十八>---> 网路编程
--------------- ASP.Net+Android+IO开发S..Net培训.期待与您交流! --------------- 第一 概述 一.概述: 1.网络模型:OSI参考模型和TCP ...
- Protobuf-net基础
本文在于巩固基础 先了解什么是protobuf Protobuf是google开源的一个项目,用户数据序列化反序列化,google声称google的数据通信都是用该序列化方法.它比xml格式要少的多, ...
- 关于我和document.write那点不得不说的事
一直用document.write()方法向浏览器中显示数据用,把它当做Alert()使用, 看来这样用有些大材小用了,下面说说它的主要用处. document.write()方法可以用在两个方面: ...
- jQuery源码笔记——数据缓存
数据缓存是为了解决内存泄露,他的原理是,当我们将数据存储到一个对象上面,实际上是将所有的数据存到一个单独的数据对象里,而这个对象只提供一个接口,这个接口可以访问自己存在数据对象里自己的数据. 这是一个 ...
- 最大稳定极值区域(MSER)检测
http://blog.csdn.net/zizi7/article/details/50379973 http://www.cnblogs.com/dawnminghuang/p/3779552.h ...
- jsp相对路径和绝对路径小谈
很长一段时间纠结过JSP中的相对路径和绝对路径,也研究过一段时间,今天趁着有点时间,记下来,也有大家分享一下. 1)我们先来理解一下相对路径 首先还是我们的开始,建一个WEB项目,只是测试一下而已,名 ...
- 第10课_dg
export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1 export ORACLE ...
- Maximum & Minimum Depth of Binary Tree
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...
- c语言中的#ifndef、#def、#endif等宏是什么意思
#ifndef.(或者#ifndef).#def.#endif等宏这几个宏是为了进行条件编译.一般情况下,源程序中所有的行都参加编译.但是有时希望对其中一部分内容只在满足一定条件才进行编译,也就是对一 ...
- JDBC连接数据库概述
直接介绍JDBC连接数据库的流程及其原理 创建一个以JDBC连接数据库的程序,包含7个步骤 1.加载JDBC数据库驱动 在连接数据库之前,首先要加载想要连接的数据库的驱动,就是数据库厂商提供的jar包 ...