Android : How to use a java class within main activity?

on Tuesday, March 31, 2015


How can I use a java class within my MainActivity, for instance I tried so that in my onCreate method within MainActivity has the layout defined, but lets say that I have a button in my layout and I added the onClickListener method to the button in my Something.java class. Simply putting new Something() in my onCreate method in my MainActivity class doesn't REGONIZE that the button has a listener that I defined in my Something.java class. Again, I don't want to create a new Activity, I just want to be able to use the onClickListener for my button that I defined in another class within MainActivity. I have tried making making Something.java into a separate activity and calling it within MainActivity and passing it MainActivity, ex: new Something(this) but nothing seems to work.


0 comments:

Post a Comment