custom method

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

custom method

Postby jjanes » Thu May 31, 2012 4:02 am

OK I have a main activity which contains 8 image buttons in it. Now when a user taps a button I replace the image with another image sort of like an buttonup image and buttondown image. When any button is oushed all the other buttons must return to the buttonup image and the one being pushed moves to the buttondown image. Since I have no idea which button is going to be pushed next. I have to first turn all buttons back to button up image then change the one that was pushed back to button down image. now if it was just the button it would be one thing but is actually multiple objects that are changing color, size, font, image etc so this allo fthese thing change when a button is pushed.

Now I am still new to OOP but I would think that I could create function to turn every button and associated items to the default settings and then focus on the one being changed to go into the pressed status.
Simply call the reset function and then porcess the activites associated with the new button press.

That way if I needed to make a change I could make it one place that custom method but HOW do I create that custom method

currently I am resetting the states in each button onclick method which is a pain
this ends up being a lot of repetitive code


I need to be able to call my custom method from the inside of the buttons onclick method which process all the button states and then continue on in the originating onclick method by setting the button pressed state as needed

This has to be able to be done but I just can't find out howor where to look.
Like I said I am still new to OOP so I may just be using the wrong terms when searching


I hope someone can explain this to me
jjanes
Freshman
Freshman
 
Posts: 7
Joined: Sat Feb 04, 2012 5:51 am

Top

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 5 guests