android nagative drawer图标跟标题适配

来源:互联网 发布:淘宝网卖围巾的店 编辑:程序博客网 时间:2024/06/01 09:50
<?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)\Android\sdk\platforms\android-15\data\res\drawable-xhdpi

0 0
原创粉丝点击