Step 3: complete the navigation bar at the bottom of the android app

Source: Internet
Author: User

Step 3: complete the navigation bar at the bottom of the android app

Many android applications have a bottom navigation bar at the bottom to facilitate User Switching during use. Currently, there are three common methods: Custom tabHost, activityGroup, and FrameLayout. After I have made multiple applications, I encapsulated an abstract class to save the development cycle. In three steps, I can generate the bottom column and call different pages.

Public class ActivitycollectiondemoActivity extends ActivityCollection {

/** Called when the activity is first created .*/

@ Override

Public void onCreate (Bundle savedInstanceState ){

Super. onCreate (savedInstanceState );

// SetBottomTabBackground (resId); // you can specify the background image of the bottom Navigation Pane.

}

@ Override

Protected boolean isShowWindowFeature (){

Return true; // set whether to display the title;

}

@ Override

Protected List SetDrawableCollections (){

List IndicatorInfos = new ArrayList ();

IndicatorInfo indicatorInfo_1 = new IndicatorInfo (R. drawable. baby1,

R. drawable. baby1_s, R. string. baby1, 12, Color. WHITE,

New Intent (ActivitycollectiondemoActivity. this,

Activity01.class ));

IndicatorInfo indicatorInfo_2 = new IndicatorInfo (R. drawable. baby2,

R. drawable. baby2_s, R. string. baby2, 12, Color. WHITE,

New Intent (ActivitycollectiondemoActivity. this,

Activity02.class ));

IndicatorInfo indicatorInfo_3 = new IndicatorInfo (R. drawable. baby3,

R. drawable. baby3_s, R. string. baby3, 12, Color. WHITE,

New Intent (ActivitycollectiondemoActivity. this,

Activity03.class ));

IndicatorInfo indicatorInfo_4 = new IndicatorInfo (R. drawable. baby4,

R. drawable. baby4_s, R. string. baby4, 12, Color. WHITE,

New Intent (ActivitycollectiondemoActivity. this,

Activity04.class ));

IndicatorInfos. add (indicatorInfo_1 );

IndicatorInfos. add (indicatorInfo_2 );

IndicatorInfos. add (indicatorInfo_3 );

IndicatorInfos. add (indicatorInfo_4 );

Return IndicatorInfos;

}

Step 1: import the jar package

Step 2: let your homeactivity inherit the ActivityCollection class

Step 3: add your image resources and jump intent to the list , Set the option

OK, an application containing the bottom navigation bar is ready. It is enough to deal with general applications. You can spend more time considering the business logic.

 

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.