开发者

Change default onListItemClick Behavior of ListView

Is there any way i can make my listactivity (rather listview) highlight the List Item when it is clicked (pressed) upon? (...and remain highlighted) The default behavior, simply highlights the item for a moment, and it gradually fades to black...

Currently, the highlighting onl开发者_如何学JAVAy happens when we use the DPad...

It'd be ideal if atleast one list item is "highlighted" at all times.

Worst case scenario, i may have to keep track of the "last clicked item" (by default the first) and change its background or something...but i was hoping there was an easier way...

Thanks in advance! :)


That isn't a good UI practice on Android; items should not be focusable, nor appear to have focus, on touch. You may want to use list items with radio boxes instead. There may be other, prettier solutions as well — I'd be happy to brainstorm if you discussed your use case.


Update: Given the new context in your comment (forward/reply/etc. contextual actions on messages), here are some other options:

  1. Use standard context menus, triggered by long-pressing on list items.
  2. Use the new Quick Actions [1] pattern as seen in the Twitter for Android app.

In either case, you can use an on-screen affordance for bringing up contextual actions, similar to the circular 'more' button inside each tweet in the Twitter app. if you'd like more discoverability.

Now, if you plan to support multi-item contextual actions, another option is to use the checkbox + slide-up action-panel UI pattern that Gmail uses.

[1] Quick Actions UI pattern, as discussed in the Android UI design patterns session at Google I/O 2010 (see slide 16 in the session slide deck). Note that although the Quick Actions code isn't in the Android SDK at the moment, Twitter for Android will be open-sourced so the code could be used in your apps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜