"Turn" Pro Android Learning Note (52): ActionBar (5): List mode

Source: Internet
Author: User

You can add spinner down menu in action Bar, for spinner, refer to Pro Android Learning Note (20): User interface and Control (8): GridView and Spinner. The style of the list is related to theme, and an exception can occur if the theme settings are incorrect.

The relevant code is as follows:

public class Listactionbardemo extends SEARCHTESTCASE3implements Onnavigationlistener{//list triggered callback function interface
@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Workwithlistactionbar ();
}

protected void Workwithlistactionbar () {
ActionBar bar = Getactionbar ();
Bar.setnavigationmode (actionbar.navigation_mode_list); Must be set to list mode, so tab and list modes do not coexist
There is no difference between the adapter set spinner and the
arrayadapter<string> myadapter = new Arrayadapter<string> (This,
Android. R.layout.simple_spinner_item,
New string[]{"One", "one"});
Myadapter.setdropdownviewresource (Android. R.layout.simple_spinner_dropdown_item);
//Load Adpter, set callback function. The first function is the Spinneradatper interface, Arrayadapter has implemented the Spinneradatper GetView () function, which can be used directly
Bar.Setlistnavigationcallbacks(Myadapter, this);
}

@Override//list triggers the callback function, which is the example, simply log.
public boolean onnavigationitemselected (int itemposition, long itemId)
{
LOG.D ("Listmode", "List Select position" + itemposition + "itemId" + itemId);
return false;
}

}

The example code covered in this blog post can be downloaded in Pro Android Learning: Actionbar Small example.

RELATED Links: My Android development related articles

"Turn" Pro Android Learning Note (52): ActionBar (5): List mode

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.