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

をプログラムで作成するときは、テキストの色を割り当てる必要がありますTextView。それ以外の場合、Androidはデフォルト(灰色)の色を使用するためです。黒は0xFF000000です。

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

他のリソースとの一貫性を保つために、このためにカラーリソースを使用することをお勧めしますTextView

于 2012-09-10T05:46:23.143 に答える