I’ve just started to learn Android, and I have a quick question. I have a separate class Team, and within it there’s 3 variables (String name, int goals, int points). In my main activity I want to increment the goals and/or points for each Team object once a button is clicked. At the moment I have a method:
public void updatePoints(View v, Team t){
t.points++;
}
and in my xml file I have:
android:onClick="updatePoints"
which relates to a Button. Can I pass a Team object like above? If so, how can it be done?
As I said I’m only starting to learn Android so any advice would be a appreciated.
Cheers
If you have….
then in your java file you need to define…
I assume in your activity you have…
Team team[]; // an array of teams (more than one), so you need to do something to identify the team your trying to update… so I’d change your definition of Team
Although you can, I wouldn’t use the tag property to identify a team… I’d use the identity field to identify individual teams. That way a team isn’t linked/tied to a button… more versatile IMHO