开发者

Android: How to work with Checked ListViews

I wish to work with checked list views wherein only one 开发者_StackOverflow社区item can be selected at a time. Some queries related to this:

  1. Is it advised to work with CheckedTextView as the ListView items, or a combination of CheckBox and TextView?

  2. If using CheckedTextView, the text comes first and the checkbox appears on the right edge. Is it possible to make the checkbox appear on the left of the TextView?

  3. How can I make one of the items as checked in onCreate()?

Note: I am using array adapter and calling setAdapter() to populate list.


You need to extend ArrayAdapter and use LayoutInflater to inflate the row layout as you need. This way you have full flexibility in list creation.

Please check this example, where basic idea is described:

Custom list view

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜