Search code examples
androidandroid-listviewgoogle-tvandroid-gridviewandroid-tablelayout

Tablelayout with selectable rows


I have a dynamically populated TableLayout.

I'm developing for GoogleTV so I need to make the rows in the TableLayout selectable by the remote D-Pad. How can I achieve that?

Am I using the wrong approach here? Should I use a GridView instead? Or maybe ListView Adapter?

I've tried to find examples and similar questions but without success.

Thanks for the help!


Solution

  • How can I make the rows user selectable (and clickable)?

    I don't know what do you understand by selectable. To make it clickable just add a OnClickListener to each of your TableRows. To visually signal the user that the row is clickable(like a Button does it when it's pressed) then use a selector drawable for the TableRow's background.

    Am I using the wrong approach here? Should I use a GridView instead? Or maybe ListView Adapter?

    A GridView no, but a ListView is a good candidate. If the table doesn't increase past the size you mention(10 x 3) you could use a simple TableLayout. If you know the TableLayout is likely to need to be scrolled(if it needs to be in a ScrollView) then a ListView will be more efficient.