Search code examples
androidtablelayouttablerowfocusable

Receiving Focus Change Events for a dynamic TableRow


I have a TableLayout that is focusable. I dynamically add to TableRows to this TableLayout.

Although I can get the TableRow, and its contents (a few TextViews), to respond to Touch events, I can't get any of them to respond to Focus events.

Aside from setting a OnFocusChangeListener, is there anything else I need to do?

TableRow tableRow = new TableRow(this); // "this" is a valid Context...
tableRow.setFocusableInTouchMode(true);
tableLayout.addView(tableRow);

TextView someNameTextView = new TextView(this);
someNameTextView.setText("Foo");
someNameTextView.setFocusableInTouchMode(true);
tableRow.addView(someNameTextView);

tableRow.setOnFocusChangeListener(someRowFocusChangeListener);
someNameTextView.setOnFocusChangeListener(someRowFocusChangeListener);

Solution

  • I was using the wrong component for the UI interaction I was looking for.