kanytu / android-material-drawer-template

An Android template with navigation drawer for material design
Apache License 2.0
674 stars 217 forks source link

Drawer somehow disables onClickListener? #12

Closed tekniksinc closed 9 years ago

tekniksinc commented 9 years ago

Added a couple of activities to the drawer list, made them implement NavigationDrawerCallbacks and added the part at the xml file. The activities open just fine, the drawer is working as it should.

The only problem is that in both the activities I added, the button onClickListeners I had are not working. Everything is displayed properly but when I press the buttons nothing happens.

The listeners are working properly without the drawer.

kanytu commented 9 years ago

I need more code to help you. But make sure you didn't remove implements onClickListener when you added the callbacks on your activities

tekniksinc commented 9 years ago

Here you can find one of the activities: http://pastebin.com/LMdaYarR

and here is the xml of it: http://pastebin.com/p2STqxzp

in the oncreate method at the top there are the 3 buttons i need (button1,2,3). At the bottom you can find the onClick method that handles the actions for the two of them.

kanytu commented 9 years ago

I'm not sure if this is the problem but you shouldn't use switch's with id's. Reformulate your onClick method to use if's instead.

tekniksinc commented 9 years ago

Nothing. I now see that in an emulator with a small screen where the views don't fit in the screen, the scrollview doesn't also work.

kanytu commented 9 years ago

You're doing it wrong. Your content of your activity should be inside the drawer layout. Not outside. You see that framelayout with the id container? There is where you change your activity's content. My sugestion would be to use fragments. Other thing you can do is to put your activitiy's XML on a new file and then call:

LayoutInflater.from(this).inflate(R.layout.myActivity,findViewById(R.id.container),true);

That line should inflate the view into the container framelayout.

tekniksinc commented 9 years ago

Such an idiot... Put it all inside the layout and it is now working properly. You're simply the best.