全てにおいて良い日。
各行に 3 つの がありますTableLayout
。行全体TextView
に追加することはまだ可能ですか? OnClickListener
選択した行の背景色を変更したいです。次のようにしてを に設定しましOnClickListener
たTableRow
が、背景色は変わりません。
for(int i =0; i < rowAmount; i++)
{
TableRow tr= new TableRow(this);
TextView rmNo;
TextView s;
TextView p;
rmNo = new TextView(this);
s = new TextView(this);
p = new TextView(this);
rmNo.setText("" + roomNumbers.get(i).toString());
s.setText("" + statuses.get(i).toString());
p.setText("" + priorities.get(i).toString());
tr.addView(rmNo);
tr.addView(s);
tr.addView(p);
tr.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
tr.setBackgroundColor(color.holo_blue_light);
}
});
tblContent.addView(tr);
}
}
データはデータベースから取得されるため、TableRows と TextViews をプログラムで作成しています。
これは XML です。
<ScrollView
android:id="@+id/scroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tblTitles">
<TableLayout
android:id="@+id/tblContent"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_below="@+id/ob">
</TableLayout>
</ScrollView>
どんな助け/アイデアも大歓迎です。
すでに検索されたソース: