ActionBar of AndroidUI Components

Source: Internet
Author: User

ActionBar of AndroidUI Components

I haven't written a blog post for a while. If I find that my blog is not complete, I will use the AndroidUI component. I will update it as soon as possible. Well, let's not talk about it. Let's take a look at ActionBar today.

According to the previous style, knowledge points are in the source code in the form of code annotations.

 

Package com. gc. actionbardemo;/*** 1. ActionBar is one of the important updates of Android3.0. The ActionBar is located at the top of the traditional title bar * That is, the displayed screen. The ActionBar displays the application icon and Activity title, that is, the content displayed at the top of the application * program. In addition, activity items can be displayed on the Right of ActionBar. * 2. ActionBar provides the following functions * (1) display menu items of the option menu (display menu items as Action items) * (2) use the program icon to return to the Home screen or navigate up * (3) provide interactive View as Action View * (4) provide a Tab-based navigation mode, it can be used to switch multiple Fragment * (5). It provides a drop-down Navigation Mode * 3. If you want to disable ActionBar, you can set the topic of the application to Xxx. noActionBar * 4. Once ActionBar is disabled, this Android app cannot use ActionBar * 5. In actual projects, it is generally recommended to use code to control the display and hiding of ActionBar, actionBar * provides the following methods to control display and 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 extends Activity {private ActionBar actionBar; @ Overrideprotected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. activity_action_bar_test); // obtain the ActionBar of the Activity. // This code returns ActionBaractionBar = getActionBar ();} only when the ActionBar is not closed for the application topic ();} // define the event handling method public void showActionBar (View source) for the "show ActionBar" button {// display ActionBaractionBar. show () ;}// defines the event handling method public void hideActionBar (View source) for the "Hide ActionBar" button {// hides ActionBaractionBar. hide ();}}


The layout file corresponding to the Activity is activity_action_bar_test. The Code is as follows:

 
  
  
 

The effect is demonstrated as follows:

 

 

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.