Android ActionBarSherlock:使用ActionBarSherlock在左侧显示/移动微调器[解决方案:使用NavigationList]
我想在《神探夏洛克》动作栏的左侧设置微调器,但由于标准行为,它将出现在右侧Android ActionBarSherlock:使用ActionBarSherlock在左侧显示/移动微调器[解决方案:使用NavigationList],android,android-actionbar,actionbarsherlock,Android,Android Actionbar,Actionbarsherlock,我想在《神探夏洛克》动作栏的左侧设置微调器,但由于标准行为,它将出现在右侧 如何修复它?好的,我通过使用navigationlist而不是在menu.xml中手动添加微调器来完成此操作: 1.列表中需要的项目必须在array.xml中定义为: <?xml version="1.0" encoding="utf-8"?> <resources> <string-array name="dashboard
如何修复它?好的,我通过使用navigationlist而不是在menu.xml中手动添加微调器来完成此操作: 1.列表中需要的项目必须在array.xml中定义为:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="dashboardItemList">
<item>Dashboard</item>
<item>Downloads</item>
<item>Revenues</item>
<item>Ads</item>
<item>Rankings</item>
<item>Reviews</item>
<item>Events</item>
</string-array>
</resources>
3.定义NavigationMethod,从array.xml获取字符串数组。并为NavigationMode设置内置布局sherlock\u spinner\u dropdown\u项。
public void setNavigationList() {
arrayItemsForDropdown = getResources().getStringArray(R.array.dashboardItemList);
Context context = getSupportActionBar().getThemedContext();
ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(context,R.array.dashboardItemList, R.layout.sherlock_spinner_item);
list.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
getSupportActionBar().setListNavigationCallbacks(list, this);
}
:)和导航列表默认情况下在ActionBarSherlock中向左对齐。检查快照
public void setNavigationList() {
arrayItemsForDropdown = getResources().getStringArray(R.array.dashboardItemList);
Context context = getSupportActionBar().getThemedContext();
ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(context,R.array.dashboardItemList, R.layout.sherlock_spinner_item);
list.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
getSupportActionBar().setListNavigationCallbacks(list, this);
}
@Override
public boolean onNavigationItemSelected(int itemPosition, long itemId) {
if (arrayItemsForDropdown[itemPosition].equals("Dashboard")) {
downloadIcon.setVisible(false);
DashboardFragment dashboardFragment = new DashboardFragment();
showFragment(R.id.fragmentContainer, dashboardFragment, "dashboard");
overridePendingTransition(R.anim.right_in, R.anim.right_out);
} else if (arrayItemsForDropdown[itemPosition].equals("Downloads")) {
Log.d("Spinner", "downloadClicked");
showProgressDialog();
new Thread(new Runnable() {
public void run() {
checkDownloadsData();
}
}).start();
}
// skipping further else parts.....
return true;
}