开发者

how to set tablelayout row background color programmatically

How开发者_JAVA技巧 to set tablelayout row background color programatically.


i found the answer at this link http://www.anddev.org/post87054.html#p87054

We need to use

tr.setBackgroundResource(R.color.red);


Use setBackgoudResource method

   TableLayout stk = (TableLayout) findViewById(R.id.table_main);



    TableRow tbrow0 = new TableRow(this);


    TextView tv0 = new TextView(this);
    tv0.setText("Sl.No ");
    tv0.setTextColor(Color.RED);
    tv0.setPadding(0,20,r,20);
    tbrow0.addView(tv0);

    TextView tv1 = new TextView(this);
    tv1.setText("Item ");
    tv1.setTextColor(Color.RED);
    tv1.setPadding(0,20,r,20);
    tbrow0.addView(tv1);

    TextView tv2 = new TextView(this);
    tv2.setText("Amount ");
    tv2.setTextColor(Color.RED);
    tv2.setPadding(0,20,r,20);
    tbrow0.addView(tv2);

    tbrow0.setBackgroundResource(R.color.cgreen);

    stk.addView(tbrow0);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜