MDNavBarView drop-down menu (imitation Meituan navigation drop-down menu ),

Source: Internet
Author: User

MDNavBarView drop-down menu (imitation Meituan navigation drop-down menu ),

When talking about the drop-down navigation menu, this is a lot of practical use. After careful calculation, this menu has been written for the third time since development, but it is basically not reusable. This is really tiring.
I accidentally saw my colleague write a similar drop-down menu, but he referenced the open-source library to copy the public menu library. After a rough look, I felt quite good and the reusability was good, but I needed

If you change to another style, you need to modify the code. This is inconvenient and error-prone. So he wrote a copy drop-down menu according to his general idea.

The specific implementation is not much said. If you find it interesting, let's take a look. The following describes how to use it:

1. Add the code and corresponding resources under the navbarview package

2. Add the following content to the layout file:

<com.mr_mo.mdnavbarview.navbarview.MDNavBarView        android:id="@+id/mdNavBarView"        android:layout_width="match_parent"        android:layout_height="match_parent">        <ListView            android:id="@+id/listView"            android:layout_width="match_parent"            android:layout_height="match_parent"/>    </com.mr_mo.mdnavbarview.navbarview.MDNavBarView>

3. Add a navigation item:

INavBarItemView itemViewAdress = new MDNavBarItemTitleView (this); itemViewAdress. setTitle ("region"); // itemViewAdress. setTitleColorSelect (Color. RED); INavBarItemView itemViewTime = new MDNavBarItemTitleView (this); itemViewTime. setTitle ("time period"); // itemViewTime. setTitleColorSelect (Color. RED); INavBarItemView itemViewFilter = new MDNavBarItemTitleView (this); itemViewFilter. setTitle ("filter"); // itemViewFilter. setTitleColorSelect (Color. RED); List list = new ArrayList (); list. add (itemViewAdress); list. add (itemViewTime); list. add (itemViewFilter); mdNavBarView. setNavBarItemView (list); mdNavBarView. setNavBarViewBGColor (Color. WHITE );

4. Add the item operation page corresponding to the navigation

MDNavBarPopupSortView sortView1 = new MDNavBarPopupSortView (this); sortView1.setBackgroundColor (Color. YELLOW); sortView1.setNavBarPopupViewHeight (210); // set the height of the drop-down menu (new NavBarPopupSelectListener () {@ Override public void onSelect (View view, int index, Object itemData) {mdNavBarView. hide (); mdNavBarView. isShowNavBarItemIcon (false, index); NavBarSortModel = (NavBarSortModel) itemData; mdNavBarView. setNavBarItemTitle (model. getTitle (), index); // update navigation title}); List listOperateView = new ArrayList (); listOperateView. add (sortView); listOperateView. add (sortView1); listOperateView. add (sortView2); mdNavBarView. setNavBarPopupOperateView (listOperateView );

 

The above describes built-in styles. The following describes how to expand your own styles.

1. Customize the items in the navigation menu. inherit the INavBarItemView and implement all the methods in the implementation class. For details, refer to MDNavBarItemTitleView. java.

2. Customize the operation interface corresponding to the navigation menu. inherit INavBarPopupView from your own implementation class and implement all the methods in it. For details, refer to MDNavBarPopupSortView. java.

Interested friends download to see: https://github.com/MrxMo/MDNavBarView

:

 

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.