Android drawer navigation, android drawer
Today I learned a simple android drawer navigation method.
Select when creating a project:
In this way, android IDE will give you a drawer navigation framework.
We only need to modify the following in the PlaceholderFragment class of MainActivity:
@ Override
Public View onCreateView (LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState ){
View rootView = inflater. inflate (R. layout. fragment_main, container,
False );
TextView textView = (TextView) rootView. findViewById (R. id. section_label );
TextView. setText ("nth" + Integer. toString (getArguments (). getInt (ARG_SECTION_NUMBER) + "partial ");
Return rootView;
}
You can display the corresponding main interface according to etArguments (). getInt to the corresponding position.
The left navigation drawer interface is easier. We only need to modify the following items in the NavigationDrawerFragment class:
@ Override
Public View onCreateView (LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState ){
MDrawerListView = (ListView) inflater. inflate (
R. layout. fragment_navigation_drawer, iner, false );
MDrawerListView
. SetOnItemClickListener (new AdapterView. OnItemClickListener (){
@ Override
Public void onItemClick (AdapterView <?> Parent, View view,
Int position, long id ){
SelectItem (position );
}
});
MDrawerListView. setAdapter (new ArrayAdapter <String> (getActionBar ()
. GetThemedContext (),
Android. R. layout. simple_list_item_activated_1,
Android. R. id. text1, new String [] {
GetString (R. string. title_section1 ),
GetString (R. string. title_section2 ),
GetString (R. string. title_section3 ),
GetString (R. string. title_section4 ),
GetString (R. string. title_section5 ),}));
MDrawerListView. setItemChecked (mCurrentSelectedPosition, true );
Return mDrawerListView;
}
This part is enough.
You can also create a general layout by modifying fragment_main.xml.
In this way, a simple navigation drawer is created.
How to enable Android mobile phone drawer
There are a lot of desktops, you can download and try it, but after a long time, I think there is nothing fun and inconvenient, my mobile desktop is simple just a few shortcut keys, other icons are hidden transparent, it is convenient, practical, and nice-looking. My desktop became more and more simple at the beginning, and I forgot to adopt it.
What is a tray and a drawer in the Android system? Can I give a legend? Thanks.
The tray is the position of the four icons at the bottom of the main interface of your mobile phone. The drawer is where you press the menu key to enter the place where you can see all the application icons.