ListView items won't show focus when touched

天大地大妈咪最大 提交于 2019-12-14 03:44:30

问题


I've got a ListView that works just great, except for this minor annoyance. I can use the trackball/dpad to move up and down my list, and the background changes according to which row has focus. But when I touch the row (click or long click), there's no background change letting me know what's been focused. I've tried setting 'focusable' and 'focusable in touch mode' to true on the rows, but it still doesn't work.

Just in case it matters somehow:

  • I am setting onClickListeners for each row.
  • The row is comprised of LinearLayouts, TextViews, and a single ImageView.
  • Focusable/clickable is 'true' for each row. Have not specified values for these on the ListView.
  • Trackable does act funny. I can only move between rows after touching inside the ListView. If I scroll trackball above the first item, it's impossible for me to scroll back into the list.

Any thoughts?


回答1:


I can use the trackball/dpad to move up and down my list, and the background changes according to which row has focus.

No, it doesn't. The background changes according to which row is selected. Selection and focus are not quite the same thing.

But when I touch the row (click or long click), there's no background change letting me know what's been focused.

"In touch mode, there is no focus and no selection."



来源:https://stackoverflow.com/questions/3078323/listview-items-wont-show-focus-when-touched

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!