0

我为我的比赛取得了高分activity。我使用表格行来输出分数。我的问题是如何更改表格行中字体的颜色,因为我看不到输出是什么。

这是我的布局代码:

<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>

这是我的高分输出的颜色activity

在此处输入图像描述

我如何将灰色的变为黑色?

这是我添加表格的方法:

{
            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);
        }

提前致谢

4

1 回答 1

0

You need to assign a text color when you create the TextViews programmatically, because Android will use its default (grey) color otherwise. Black is 0xFF000000.

TextView textOne = new TextView(this);
textOne.setTextColor(0xFF000000);
textOne.setText(row.get(1).toString());
tableRow.addView(textOne);

Note that you may want to use a color resource for this to keep it consistent with your other TextViews.

于 2012-09-10T05:46:23.143 回答