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)\Android\sdk\platforms\android-15\data\res\drawable-xhdpi

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值