Saturday, 31 August 2013

Different text color for each class object?

Different text color for each class object?

I'm making some kind of "game score tracker". Here's how the app currently
works:
User adds players by typing a name into EditText and then clicking ok button.
After the user finished adding new players, he presses "start game" button
and a new activity opens.
Players are added to Parcelable extra and taken to the next activity.
In the next activity, a user has a spinner, EditText and +, - buttons.
After the user selects a certain player from the spinner, types in a
certain score and then either a + or -, a new TextView will appear
containing Player name and score.
Example: If there are 3 Players "James, John and Robert". The user then
adds 5 points to James, 10 points to John and 15 points to Robert. This is
how TextViews will look like:
James 5
John 10
Robert 15
Then if user will do the exactly same thing again, this will happen:
James 5
John 10
Robert 15
James 10
John 20
Robert 30
So as you can see, I don't keep the same TextView for each player but I
keep adding them (I do want that, I want the user to be able to see his
actions, when he clicked - and when +. But is there a way to somehow set a
color for each user? Example: James will be blue, John will be red and
Robert will be green. How do I pre-determine the color of each Player's
TextView?
Player class:
public static class Player implements Parcelable{
String name;
int score;
@Override
public int describeContents() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(score);
dest.writeString(name);
}
public Player(Parcel source){
score = source.readInt();
name = source.readString();
}
public Player(){
}
public static final Parcelable.Creator<Player> CREATOR = new
Parcelable.Creator<Novaigra.Player>() {
@Override
public Player createFromParcel(Parcel source) {
return new Player(source);
}
@Override
public Player[] newArray(int size) {
return new Player[size];
}
};
}
Can I add some kind of color palette to the activity when players are
being added so that a user can pre-determine a color or something?

No comments:

Post a Comment