java - NavigationDrawer Fragment Styling/Icon -


I have tried some other stack overflow and Google-solution, but they did not work (,)

I want to make the navigation drawer style but I do not know, which code should I change

  • active object
  • pressed / centered item
  • / ul>

    And I want to add an icon before the list item too!

    Here is the activity where the content is loaded and the drawer is shown:

    activity_main_window.xml:

     < Code> & lt ;! - A bidet's outout is used as the top-level content view using match_parent for both the fourth and the eighth space available. - & gt; & Lt; Android.support.v4.widget.DrawerLayout xmlns: Android = "http://schemas.android.com/apk/res/android" xmlns: tools = "http://schemas.android.com/tools" Android: Id = "@ + Id / drawer_layout" Android: layout_width = "match_parent" Android: layout_height = "match_parent" tool: reference = "bernd.slider" & gt; & Lt; FrameLayout Android: id = "@ + id / container" Android: layout_width = "match_parent" Android: layout_height = "match_parent" /> & Lt ;! - Drawer has been given a fixed width in DP and increases the height of the container - & gt; & Lt; Piece android: id = "@ + id / navigation_drawer" Android: layout_width = "@ Dimen / navigation_drawer_width" Android: layout_height = "match_parent" Android: layout_gravity = "start" android: name = "bernd.slider.NavigationDrawerFragment" tool: Layout = "@ Layout / fragment_navigation_drawar" /> & Lt; /android.support.v4.widget.DrawerLayout>  

    and here fragment_navigation_drawer.xml: (where archived in the list view)

      & lt; ListView 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" Android: ChoiceMode = "SingleChoice" android: divider = "@ color / Darkred" Android: DividerHeight = "LDP" android: background = "@ color / white" equipment manual = "BerndksliderkNavigationDrawerFragment" Android: ID = "@ + ID / Navigation_drawar" />  

    I should mention this code:

    from main_window.java:

      @Override Secure Zero on Crate (Bundle Saved Instantstate) {Super. Contents (Saved Instantstate); SetContentView (R.layout.activity_user_area); MNavigationDrawerFragment = (Navigation DrawerFragment) getFragmentManager (). FindFragmentById (R.id.navigation_drawer); MTitle = getTitle (); (1) onSectionAttached; // Set the title for the homepage // set the drawer MNavigationDrawerFragment.SsetUp (R.id.navigation_drawer, (DrawerLayout) findViewById (R.id.drawer_layout)); }  

    The NavigationDrawerFragment.java:

      @Override public view onCreateView (LayoutInflater inflater, ViewGroup container, bundle savedInstanceState) { MDrawerListView = (ListView) inflater.inflate (R. Late Fragment_Navigation_Drown, Container, False); mDrawerListView.setOnItemClickListener (New AdapterView.OnItemClickListener () {@Override to view public void onItemClick (AdapterView & LT ;? & gt; parents, see, int position, long id) {selectItem (position);}}); mDrawerListView.setAdapter (New ArrayAdapter & LT; string & gt; (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),})); MDrawerListView.setItemChecked (mCurrentSelectedPosition, true); Return mDrawerListView; }  

    It is important that I use a piece manager to load the content from a particular page to R.id.container (activity_main_window.xml) I am here.

    So how can I change style? I do not understand that ...

  • You can change the style in your ListViewAdapter. I would consider creating a custom adapter and extending it to the basidator. You can go again:

      mDrawerListView.setAdapter (new myCustomAdapter);  

    Or, what I did once, do not use a list view for your drawer frames:

      mDrawerListView = (ListView) inflater.inflate (R) .layout .your_custom_fragment, container, incorrect); You can insert whatever you want into "R.layout.your_custom_fragment".  

    If the items in the ListView are not dynamic, then insert some textviews into a virtual linear timepiece.

    Hope it helps.


    Comments

    Popular posts from this blog

    java - Can't add JTree to JPanel of a JInternalFrame -

    javascript - data.match(var) not working it seems -

    javascript - How can I pause a jQuery .each() loop, while waiting for user input? -