I have made a high score activity for my game. i used table row for the output of the scores. My question is that how can i change the color of the fonts in my table row because i cannot see what’s the output.
Here’s my layout code:
<TableLayout
android:id="@+id/data_table"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="invisible"
>
<TableRow android:visibility="invisible" >
<TextView
android:layout_marginLeft="65dp"
android:visibility="invisible"
android:text="#"
android:textColor="#000000" />
<TextView
android:visibility="invisible"
android:text="Score"
android:textColor="#000000" />
<TextView
android:visibility="invisible"
android:text="Player"
android:textColor="#000000" />
</TableRow>
</TableLayout>
Here’s the color of my output in high score activity.
How will i change the gray one to black?
here’s how i add the table:
{
TableRow tableRow= new TableRow(this);
ArrayList<Object> row = data.get(position);
TextView idText = new TextView(this);
idText.setText(row.get(0).toString());
tableRow.addView(idText);
TextView textOne = new TextView(this);
textOne.setText(row.get(1).toString());
tableRow.addView(textOne);
TextView textTwo = new TextView(this);
textTwo.setText(row.get(2).toString());
tableRow.addView(textTwo);
dataTable.addView(tableRow);
}
Thanks in advance
You need to assign a text color when you create the
TextViews programmatically, because Android will use its default (grey) color otherwise. Black is0xFF000000.Note that you may want to use a color resource for this to keep it consistent with your other
TextViews.