Android menu using slide menu library

929 views Asked by At

I am using sliding menu library in my project it was working nice, but I uninstalled my app from the device and installed it again through Eclipse. The size of the app was reduced from 7.92 MB to 6.92 MB. And where the sliding menu should appear in an Activity, it is not opening and the following errors are in my logcat.

Logcat

        11-17 17:58:52.241: E/AndroidRuntime(4049): FATAL EXCEPTION: main
        11-17 17:58:52.241: E/AndroidRuntime(4049): Process: com.example.sayminicabdriver, PID:   4049
        11-17 17:58:52.241: E/AndroidRuntime(4049): java.lang.RuntimeException: Unable to start                   activity ComponentInfo{com.example.sayminicabdriver/mapslider.sliding}:              java.lang.NullPointerException
        11-17 17:58:52.241: E/AndroidRuntime(4049):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
        11-17 17:58:52.241: E/AndroidRuntime(4049):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
        11-17 17:58:52.241: E/AndroidRuntime(4049):     at android.app.ActivityThread.access$800(ActivityThread.java:135)
        11-17 17:58:52.241: E/AndroidRuntime(4049):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
        11-17 17:58:52.241: E/AndroidRuntime(4049):     at android.os.Handler.dispatchMessage(Handler.java:102)
        11-17 17:58:52.241: E/AndroidRuntime(4049):     at android.os.Looper.loop(Looper.java:136)
        11-17 17:58:52.241: E/AndroidRuntime(4049):     at android.app.ActivityThread.main(ActivityThread.java:5001)
        11-17 17:58:52.241: E/AndroidRuntime(4049):     at java.lang.reflect.Method.invokeNative(Native Method)
        11-17 17:58:52.241: E/AndroidRuntime(4049):     at java.lang.reflect.Method.invoke(Method.java:515)
        11-17 17:58:52.241: E/AndroidRuntime(4049):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
        11-17 17:58:52.241: E/AndroidRuntime(4049):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
        11-17 17:58:52.241: E/AndroidRuntime(4049):     at dalvik.system.NativeStart.main(Native Method)
        11-17 17:58:52.241: E/AndroidRuntime(4049): Caused by: java.lang.NullPointerException
        11-17 17:58:52.241: E/AndroidRuntime(4049):     at android.view.ViewGroup.addView(ViewGroup.java:3353)
        11-17 17:58:52.241: E/AndroidRuntime(4049):     at android.view.ViewGroup.addView(ViewGroup.java:3336)
        11-17 17:58:52.241: E/AndroidRuntime(4049):     at com.jeremyfeinstein.slidingmenu.lib.CustomViewAbove.setContent(CustomViewAbove.java:436)
        11-17 17:58:52.241: E/AndroidRuntime(4049):     at com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.setContent(SlidingMenu.java:356)
        11-17 17:58:52.241: E/AndroidRuntime(4049):     at com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.attachToActivity(SlidingMenu.java:332)     
        11-17 17:58:52.241: E/AndroidRuntime(4049):     at com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.attachToActivity(SlidingMenu.java:292)
        11-17 17:58:52.241: E/AndroidRuntime(4049):     at mapslider.sliding.onCreate(sliding.java:122)
        11-17 17:58:52.241: E/AndroidRuntime(4049):     at android.app.Activity.performCreate(Activity.java:5231)
        11-17 17:58:52.241: E/AndroidRuntime(4049):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
        11-17 17:58:52.241: E/AndroidRuntime(4049):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
        11-17 17:58:52.241: E/AndroidRuntime(4049):     ... 11 more

My code was running well for me before, but suddenly this error came.

java code

                      @Override
                      public void onCreate(Bundle savedInstanceState) {
                      super.onCreate(savedInstanceState);
                      setBehindContentView(R.layout.content_frame);
                      SlidingMenu menu_bus = new SlidingMenu(this);
                      SlidingMenu sm = getSlidingMenu();
                      sm.setShadowWidthRes(R.dimen.shadow_width);
                      sm.setShadowDrawable(R.drawable.shadow);
                      sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
                      sm.setFadeDegree(0.35f);
                      sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);

                      menu_bus.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
//firs slide menu, then second
                     getSlidingMenu().setMode(SlidingMenu.LEFT_RIGHT);
                  getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, new                       MenuFragment()).commit();

        getSlidingMenu().setBehindOffset(50);                  
     //   getSupportActionBar().setDisplayShowCustomEnabled(true);
      //  getSupportActionBar().setDisplayHomeAsUpEnabled(true);        

        getSlidingMenu().setSecondaryMenu(R.layout.right_main);
        getSlidingMenu().setSecondaryShadowDrawable(R.drawable.shadowright);
//start fragment for second menu
getSupportFragmentManager()
.beginTransaction()
.add(R.id.right_container, new RightFragment(),"test_bus")
.commit();

         Button csButton=(Button)findViewById(R.id.button1);


        csButton.setOnClickListener(new OnClickListener() {


    @Override
    public void onClick(View arg0) {
        // TODO Auto-generated method stub
        getSlidingMenu().showMenu();

    }//inside csButton1 onclick listener just need to call 

});
   // inside csButton onclick listener just need to call slidingMenu.showSecondaryMenu();
     Button csButton1=(Button)findViewById(R.id.button2);
   csButton1.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub

        getSlidingMenu().showSecondaryMenu();

    }
}) ;

Thanks in advance.

1

There are 1 answers

2
wanz On

Try to clean the project and make sure the library is used (right click project, properties) or in java built path