Actionbar of Androidui Components

Source: Internet
Author: User
Tags home screen

For a period of time did not write the blog, found that the integrity of their blog is not very good, take androidui components this piece, has not been updated, I will update as soon as possible. Well, not much to say, today to see the Actionbar.

In the past, knowledge points are in the source code in the form of code annotations.

Package com.gc.actionbardemo;/** * 1, Activity Bar (ActionBar) is one of Android3.0 's important updates. Actionbar is located in the position of the traditional title bar * That is, the top of the displayed screen. The Actionbar can display the app's icon and activity title---which is what is displayed at the top of the app's program. In addition, the right side of Actionbar can also display active items. * 2, Actionbar provides the following functions * (1) Display the menu item of the Options menu (Display item as action Item) * (2) Use program icon as back home screen or up navigation operation * (3) Provide interactive view as Action View * (4) For tab-based navigation, which can be used to toggle multiple fragment * (5) to provide a pull-based navigation method * 3, if you want to turn off Actionbar, you can set the theme for the app to Xxx.noactionbar * 4, once the Actionbar is turned off, The Android app will not be able to use ActionBar * 5, the actual project, usually recommend the use of code to control ActionBar display, hide, ActionBar * Provides the following methods to control the display, hide. * Show (): Show ActionBar * Hide (): Hide ActionBar */import android.os.bundle;import android.app.actionbar;import Android.app . Activity;import android.view.menu;import android.view.view;/** * * @author Android General * */public class Actionbartest Exten DS Activity {private ActionBar ActionBar; @Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate ( Savedinstancestate); Setcontentview (r.layout.activity_action_bar_test);//Get the activity's actionbar// The code can return Actionbar only if the app theme does not close ActionbarActionbar=getactionbar ();} Defines the event handling method for the show Actionbar button public void Showactionbar (View source) {//display actionbaractionbar.show ();} Defines the event handling method for the "Hide Actionbar" button public void Hideactionbar (View source) {//Hide actionbaractionbar.hide ();}}


The layout file for the activity is activity_action_bar_test, and the code looks like this:

<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= "show Actionbar"/>    <button        android:onclick= " Hideactionbar "        android:layout_width=" wrap_content "        android:layout_height=" Wrap_content "        Android : text= "Hide Actionbar"/></linearlayout>

The results are shown below:


Reprint Please specify source: http://blog.csdn.net/android_jiangjun/article/details/38230733

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.