Search code examples
androidandroid-activitysliding

Android sliding menu force closed


I created a sliding menu with the library https://github.com/jfeinstein10/SlidingMenu. I created my own login view instead of slide menu succesfully with the code

    public class MainActivity extends Activity  {

     @Override
     public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_main);

     SlidingMenu menu = new SlidingMenu(this);
     menu.setMode(SlidingMenu.LEFT);
     menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
     menu.setShadowWidthRes(R.dimen.shadow_width);
     menu.setShadowDrawable(R.drawable.shadow);
     menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
     menu.setFadeDegree(0.35f);
     menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
     menu.setSecondaryMenu(R.layout.login);


   }}

Now I want to make some action in login.SO how can I do this.I tried within the same main activty. but it force closed, how can I do some action in login and where should I code ?? I am new to android so please help me and thanks :)


Solution

  • I had the same problem.Please check Slidingmenu.java in the library and make your code in function public void setsecondarymenu()

    eg: if you want to settext to a textview

             public void setSecondaryMenu(int res) {
        setSecondaryMenu(LayoutInflater.from(getContext()).inflate(res, null));
        TextView tv=(TextView)findViewById(R.id.tv);
        tv.setText("helloo i got it :)");
         }
    

    make sure that u have a layout in library that you want to view hope this will help you :)