Question

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);
Was it helpful?

Solution 2

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

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top