I would like to have icons next to my items in my navigation drawer that I have set up like this:
Titles = getResources().getStringArray(R.array.array1);
Icons = getResources().getIntArray(R.array.icons);
mDrawerLayout = (DrawerLayout)findViewById(R.id.Welcome);
mDrawerList = (ListView) findViewById(R.id.left_drawer);
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
mDrawerList.setAdapter( new ArrayAdapter<String>(this, R.layout.drawer_list_item, Titles));
I know that the process must involve adding an image view to the text view that is in the XML for the drawer_list_item but I'm not sure how to do that. What is the best way to accomplish this?
This is my drawer_list_item.xml:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:textColor="#111"
android:background="?android:attr/activatedBackgroundIndicator"
android:minHeight="?android:attr/listPreferredItemHeightSmall"/>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…