Simple application of Actionbar

Source: Internet
Author: User

ActionBar ab = This.getactionbar ();
Ab.setdisplayhomeasupenabled (TRUE);

The thing to note here is that if the minimum version of your manifest file is less than 3.0 error, you must have a version greater than 3.0

The first thing to do is create a Actionbar

Then add the Actionbar click Method to the Activity

public boolean onmenuitemselected (int featureid, MenuItem item) {
TODO auto-generated Method Stub
Switch (Item.getitemid ()) {
Case Android. R.ID.HOME://the default ID value and then closes the current activity to
Finish ();
Break

Case R.id.addpeople:
Intent Intent = new Intent (Mylinkmanactivity.this,
Addlinkmanactivity.class);
StartActivity (Intent);
Break
}
Return super.onmenuitemselected (Featureid, item);
}

Each activity has a menu, and we want to insert the function into bar via the XML file inside.

In summary, some of the usual functions will be put in the Actionbar.

Simple application of Actionbar

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.