您的位置:首页 > 移动开发 > Android开发

android nagative drawer图标跟标题适配

2016-04-19 18:08 573 查看
<?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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: