我正在尝试为应用程序创建一个设置屏幕,并且我喜欢 Gmail 应用程序的设置屏幕。这是一个屏幕截图:
它看起来/行为就像某种自定义列表。
左侧看起来像一个 TwoLineListItem(或者只是一个大 TextView 和小 TextView)。
右侧是复选框、空白或向下箭头(如 ExpandableListView),指示您应该按下它。 (例如:当您按“签名”项时,会出现一个对话框,以便您输入签名)。
我认为其中一个棘手的部分是整个列表项是一个“按钮”,这意味着您不必直接按复选框来选中它,您可以按列表项上的任何位置。
例如,本教程的第 5.2 节 http://www.vogella.de/articles/ AndroidListView/article.html 要求您准确点击复选框而不是整个列表项。
有人对如何做到这一点有任何想法吗?
I'm trying to create a settings screen for an app and I like the Gmail app's settings screens. Here is a screenshot:
It looks/behaves like a custom list of some sort.
The left side looks like a TwoLineListItem (or just a large TextView and small TextView).
The right side is either a checkbox, a blank, or a downward arrow (like ExpandableListView) to indicate you should press it. (ex: when you press the Signature item, a dialog appears so you can input a signature).
I think one tricky part of this is that the entire list item is a "button", meaning you don't have to press directly on the checkbox to check it, you can press anywhere on the list item.
For example, section 5.2 of this tutorial http://www.vogella.de/articles/AndroidListView/article.html requires you tap exactly on the checkbox rather than on the entire list item.
Anyone have any ideas on how this is done?
发布评论
评论(2)
这不是“正常”的列表视图。
该 UI 是使用 PreferenceActivity 构建的
始终使用
PreferenceActivity< /code> 显示应用程序的设置。
This is not the 'normal' listView.
That UI was built with the PreferenceActivity
Always use the
PreferenceActivity
to display settings for your application.您好,您可以使用 OnItemClickListener “http://developer.android.com/reference/android/widget/AdapterView.html#setOnItemClickListener%28android.widget.AdapterView.OnItemClickListener%29” ListView 的 rel="nofollow">setOnitemClickListener() 方法。每当触摸列表项时都会调用侦听器。在侦听器中,您可以显示下拉菜单,也可以使用复选框的
setChecked(booleanchecked)
方法将复选框设置为“已选中”。Hi you can easily define an OnItemClickListener with the setOnitemClickListener() method of the ListView. The Listener is called whenever a list item is touched. In the Listener you can either show the dropdown menu or set the Checkbox to 'checked' with the
setChecked(boolean checked)
method of the Checkbox.