Android Project Combat-recite the words dev05-the main interface custom menu

Source: Internet
Author: User

This article explains

The main interface to customize the bottom menu to use the explanation

The main interface is that day task interface fragmentactivity

Customizing menu functionality requires importing V1uilibrary.

Source Address: Https://github.com/vomzoo/VOMAndroidUILib

In the main interface just call the custom menu, specific implementation temporarily see V1uilibrary source code

Effect

Flow chart

Main UI Features

1> rewrite Oncreateoptionsmenu and add an item

/**   * To customize menu, you must create an  item */@Overridepublicboolean  Oncreateoptionsmenu (Menu menu) {      menu.add ("menu");       return Super . Oncreateoptionsmenu (menu);}

2> override onmenuopened to intercept the default menu and set menu

/*** Block Menu * Returns FALSE, indicating that the custom menu is displayed*/@Override Public BooleanOnmenuopened (intFeatureid, Menu menu) {      if(Custommenupopupwindow! =NULL) {         if(Custommenupopupwindow.isshowing ()) {Custommenupopupwindow.dismiss (); } Else {             //Display window//To set the location that layout displays in PopupwindowCustommenupopupwindow.showatlocation ( This. Findviewbyid (r.id.todaytasklinearlayout), Gravity.bottom| Gravity.center_horizontal, 0, 0); }      }      return false;}

3> Create an implementation Onitemclicklistener class to set the Menu Items

/*** Menu click event * Click to jump*/  classBodyclickeventImplementsOnitemclicklistener {@Override Public voidOnitemclick (adapterview<?> adapterview, view view,intposition,LongArg3) {         if(Position! = 2) {context.startactivity (NewIntent (context, resultclassarray[position])); if(Custommenupopupwindow.isshowing ()) {Custommenupopupwindow.dismiss (); }            if(Position = = 1) {activity.finish (); }         } Else{Systemutil.exitapp (activity); }      }}

4> Initial Customization Menu

/**   * Initialize to create a custom menu  * Third parameter, menu background, 0 for white   */    privatevoid  Initnewpopupwindow () {      new  Custommenupopupwindow (            thisnew  bodyclickevent (), systemutil.screenheight);      Custommenupopupwindow.setbodyadapter (Bodyadapter);   }

More please download the Source code interpretation

Application Download: please click

Source Download: please click

Android Project Combat-recite the words dev05-the main interface custom menu

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.