0

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);
Jay Bose
  • 1,511
  • 2
  • 11
  • 14

2 Answers2

0

Are you actually calling setFocusable (see http://developer.android.com/reference/android/view/View.html#setFocusable%28boolean%29) on the Views and TableRows?

Femi
  • 64,273
  • 8
  • 118
  • 148
  • Femi, I did. Just to test things out, I changed the TextView instances to EditText instances, and the focus worked just fine. I'm thinking maybe I need to move away from the TableLayout, and stick with ListViews. – Jay Bose May 20 '11 at 00:24
0

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

Jay Bose
  • 1,511
  • 2
  • 11
  • 14