Change background color of selected item in Navigationdrawer

Asked

Viewed 648 times

0

How can I change the background color of the selected item in Navigationdrawer?

inserir a descrição da imagem aqui

<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="@android:color/transparent"
    android:dividerHeight="0dp"
    android:background="#d2191919"
    tools:context=".NavigationDrawerFragment"
    android:drawSelectorOnTop="false" />

Mainactivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Hide Action Bar
    getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
    getActionBar().hide();

    setContentView(R.layout.activity_main);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    mNavigationDrawerFragment = (NavigationDrawerFragment)
            getFragmentManager().findFragmentById(R.id.navigation_drawer);
    mTitle = getTitle();

    // Set up the drawer.
    mNavigationDrawerFragment.setUp(
            R.id.navigation_drawer,
            (DrawerLayout) findViewById(R.id.drawer_layout));

    addListenerOnButton();

    v = mNavigationDrawerFragment.getView();

}
  • The change will be made on the items in your list and not on itself ListView. Put in more codes so we can see. For example, how do you mount the adapter?

  • I haven’t assembled any Adapter yet but I’m doing all the initializations of the MenuDrawer in the onCreate

  • You do not have a layout to "inflate" these items within the ListView?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.