android nagative drawer图标跟标题适配

<?xml version="1.0" encoding="utf-8"?>
<resources>

   <string name="app_name">xxx</string>    
    <string name="navigation_drawer_open">Open navigation drawer</string>
    <string name="navigation_drawer_close">Close navigation drawer</string>
    <string name="action_example">Example action</string>
    <string name="action_settings">Settings</string>
    赵存档 QQ463431476
    <string-array name="sections">
    <item>xxx</item>
  
</string-array>
<string-array name="section_titles">
    <item>xxx</item>
   
</string-array>
<string-array name="sections_icons">
    <item>@drawable/see</item>
    <item>@drawable/settings</item>
    <item>@drawable/figure</item>
    <item>@drawable/wifi</item>
    <item>@drawable/mic</item>
    <item>@drawable/voice</item>
</string-array>

http://www.cnblogs.com/xiaobo-Linux/  QQ463431476

http://www.cnblogs.com/xiaobo-Linux/

public void onSectionAttached(int number) { //标题 String[] stringArray = getResources().getStringArray(R.array.section_titles); mTitle = stringArray[number-1]; switch (number) { case 1: getSupportFragmentManager().beginTransaction() .replace(R.id.container, new Robot()).commit(); break; } }
  //数据适配器 
        final TypedArray typedArray = getResources().obtainTypedArray(R.array.sections_icons);
        mDrawerListView.setAdapter(new ArrayAdapter<String>(
                getActionBar().getThemedContext(),
                android.R.layout.simple_list_item_activated_1,
                android.R.id.text1,
                getResources().getStringArray(R.array.sections)
        ) {
            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                View v = super.getView(position, convertView, parent);
                int resourceId = typedArray.getResourceId(position, 0);
                Drawable drawable = getResources().getDrawable(resourceId);
                ((TextView) v).setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
                return v;
            }
        });
        

@android:drawable/xxx 是调用sdk安卓系统自带的图片

C:Program Files (x86)Androidsdkplatformsandroid-15data esdrawable-xhdpi

原文地址:https://www.cnblogs.com/zhaocundang/p/5409234.html