1

How to Call an Activity while using Side Navigation in Android.

I am using this sample :Navigation menu for Android (based off Google+ app)

https://github.com/darvds/RibbonMenu

Here i want, whenever user will click on Home then need to call CategoryActivity and when do click on Home2 then need to call OptionsActivity and so on.....

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

    }
         }            

ribbon_menu.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>

I want to call activities by using particular Side Bar Navigation Item:

Home > CategroyActivity

Home2 > OptionsActivity

Home3 > ArrowActivity

Jimmy Hill
  • 216
  • 2
  • 5
  • 15

2 Answers2

0

you have got a null pointer in getActionBar().setDisplayHomeAsUpEnabled(true);

getActionBar() returns null. there could be couple of reasons for this, most probably this could be an issue of your project setup. check your AndroidManifest.xml and remove if you have set a "fullscreen" or "no title bar" theme.

Asanka Senavirathna
  • 4,570
  • 4
  • 18
  • 20
0

I was facing the same issue. Solution for this problem is you need to use Fragment instead of Activity. Best Example here: http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer/

Ronak Vala
  • 23
  • 7