如何在 Android 中使用侧边导航时调用 Activity。
我正在使用这个示例:Android 的导航菜单(基于 Google+ 应用程序)
https://github.com/darvds/RibbonMenu
在这里,我想要,每当用户单击Home时需要调用CategoryActivity并且何时单击Home2然后需要调用OptionsActivity等等.....
RibbonsampleActivity.Java:
public class RibbonsampleActivity extends Activity implements iRibbonMenuCallback {
/** Called when the activity is first created. */
private RibbonMenuView rbmView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
rbmView = (RibbonMenuView) findViewById(R.id.ribbonMenuView1);
rbmView.setMenuClickCallback(this);
rbmView.setMenuItems(R.menu.ribbon_menu);
getActionBar().setDisplayHomeAsUpEnabled(true);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == android.R.id.home) {
rbmView.toggleMenu();
return true;
} else {
return super.onOptionsItemSelected(item);
}
}
@Override
public void RibbonMenuItemClick(int itemId) {
// Handle item selection
}
}
功能区菜单.xml:
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/ribbon_menu_home" android:title="Home" android:icon="@drawable/ic_launcher"></item>
<item android:id="@+id/ribbon_menu_home2" android:title="Home2" android:icon="@drawable/ic_launcher"></item>
<item android:id="@+id/ribbon_menu_home3" android:title="Home3" android:icon="@drawable/ic_launcher"></item>
我想通过使用特定的侧栏导航项来调用活动:
首页 > 类别活动
Home2 > 选项活动
Home3 > 箭头活动