About how to use the bottom menu bar..., use the bottom menu bar ..
To use it, first, you need to reference your library to your current project. The operation method is as follows: Right-click your current project and choose Congfig build path under Build Path, go to android, click add, and your library's project will be displayed. Double-click it to OK.
If the above steps are OK, use your framework now. Details
The application code is attached below.
Package com. example. bluetooth;
Import java. util. ArrayList;
Import android. app. Activity;
Import android. app. Fragment;
Import android. app. FragmentManager;
Import android. app. FragmentTransaction;
Import android. OS. Bundle;
Import android. view. Window;
Import android. widget. LinearLayout;
Import com. weight. tabbottomlib. view. Item;
Import com. weight. tabbottomlib. view. MyBottomLayout;
Import com. weight. tabbottomlib. view. MyBottomLayout. ICallbackLister;
Public class MainActivity extends Activity {
MyBottomLayout bot;
ArrayList <Item> itemData = new ArrayList <Item> ();
LinearLayout myContent;
@ Override
Protected void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
This. requestWindowFeature (Window. FEATURE_NO_TITLE );
SetContentView (R. layout. activity_main );
Init ();
}
/**
* Initialization Method
*/
Private void init (){
FindId ();
InitData ();
SetPageContent (new HomeFragment ());
Initclick ();
}
/**
*
* @ Title: setPageContent
* @ Description: Set the content of the page.
* @ Param fragment: Fragment of the submitted content
* @ Return
* @ Throws
*/
Public void setPageContent (Fragment fragment ){
FragmentManager manager = getFragmentManager ();
FragmentTransaction ft = manager. beginTransaction ();
Ft. replace (R. id. context, fragment );
Ft. commit ();
}
/**
* Initialize data in the bottom menu bar
*/
Private void initData (){
For (int I = 0; I <3; I ++ ){
Switch (I ){
Case 0:
// Item. setDrawableNormalId ();
Item item = new Item (R. drawable. bottom_fp_nor,
R. drawable. bottom_fp_pre, "Homepage ");
ItemData. add (item );
Break;
Case 1:
Item item1 = new Item (R. drawable. bottom_ph_nor,
R. drawable. bottom_ph_pre, "companion nurse ");
ItemData. add (item1 );
Break;
Case 2:
Item item2 = new Item (R. drawable. bottom_bbs_nor,
R. drawable. bottom_bbs_pre, "escort time ");
ItemData. add (item2 );
Break;
}
}
Bot. addBottomLayoutValue (itemData );
}
/**
* Find the id
*/
Private void findId (){
Bot = (MyBottomLayout) findViewById (R. id. bottom );
MyContent = (LinearLayout) findViewById (R. id. context );
}
/**
* Callback for initialization click events
*/
Private void initclick (){
Bot. setOnCallbackLister (new ICallbackLister (){
@ Override
Public void click (int id ){
Switch (id ){
Case 0:
SetPageContent (new HomeFragment ());
Break;
Case 1:
SetPageContent (new EscortTeacher ());
Break;
Case 2:
SetPageContent (new EscortTime ());
Break;
}
}
});
}
}
Then, enter the package name + class name of your control in your layout file. The detailed xml file is as follows:
<RelativeLayout xmlns: android = "http://schemas.android.com/apk/res/android"
Xmlns: tools = "http://schemas.android.com/tools"
Android: layout_width = "match_parent"
Android: layout_height = "match_parent">
<Com. weight. tabbottomlib. view. MyBottomLayout
Android: id = "@ + id/bottom"
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Android: layout_alignParentBottom = "true"
Android: background = "#9000">
</Com. weight. tabbottomlib. view. MyBottomLayout>
<LinearLayout
Android: id = "@ + id/context"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
Android: layout_above = "@ id/bottom"
Android: orientation = "horizontal">
</LinearLayout>
</RelativeLayout>
Let's take a look at the results.
Now let's take a look at the effect. I personally think this is very useful, and the switching of the Bottom page is also achieved.
I am also a newbie. If anything is wrong, please kindly advise.