开发者

android : How to assign default theme color to TableRow

I have a table in which I add rows dynamically. By default when a row is clicked, nothing is changed so user can't get notification of which row is seected. I want to set the default theme background color for onClick event of row. The main purpose of this is to match its selection with other components of the application.

EDIT : To make it simpler and easy to understand, here's the exact scenario : I have a tablayout, that has a tablelayout in it. I am adding TableRow's dynamically that contians 3 TextView's. On selecting a tab, i开发者_开发技巧ts color changes fron Gray to Whitish. I want the same color setting to be done on my row selected. In any situation, I want to make sure that whatever is the color for tab selection that same color is applied to row selection.

This is what my exact requirement is and am looking for a solution from last 2 days. But can't find anything proper. At present I am changinf row selection by :

currSelectedRow.setBackgroundResource(android.R.drawable.divider_horizontal_bright); // .list_selector_background);

"list_selector_background" occupies that much length below the row and on next row selection that spcae is not evned out. So spaces are left between rows here and there. Similarly, I also tried with "tab...." that also caused the almost same results as list_selector. At present have just used "divider_horizontal_bright" to get the idea of which row is selected. But doesn't get my solution.

I want the selectedtion background colro of tab to be applied to background color of row.

How do I get this info and set the color of the row selected ?


Thanks @Krishna, But that didn't work out for me. I implemented using onFocusListener and onClick on Table Row and that worked out perfectly. I wanted to use selector, but I guess ..

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜