Pergunta

Eu tenho um TableLayout que pode ser focado.Eu adiciono dinamicamente TableRows a este TableLayout.

Embora eu consiga fazer com que o TableRow e seu conteúdo (alguns TextViews) respondam aos eventos Touch, não consigo fazer com que nenhum deles responda aos eventos Focus.

Além de definir um OnFocusChangeListener, há mais alguma coisa que preciso fazer?

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);
Foi útil?

Solução 2

Eu estava usando o componente errado para a interação da interface do usuário que procurava.

Outras dicas

Você está realmente ligando setFocusable (ver http://developer.android.com/reference/android/view/View.html#setFocusable%28boolean%29) no Viewareia TableRowé?

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top