这个问题可能已经被问了很多次在这里,没有得到有用的答案。我想在这里把它与一个可能的答案。随意提高。的
问:如何设置弹出类似的细节视图风格,在并排大师细节图,如下图所强调的:
Question: How to setup popup like style of detail view, in side by side master detail view as highlighted in image below:
在这个解决方案中,我使用的9补丁背景图像,确定2种背景的列表项。因此,选择(选中)列表项目都有不同的背景,如下所示:
In this solution , I have used 9-patch background images, to define 2 kinds of backgrounds for list items. So, the selected(checked) list Item has a different background, as shown:
(列表项)
(list item)
(选择项)
(selected item)
(列表项)
(list item)
列表项布局的父视图,是一类延伸的LinearLayout
(可以是任何的ViewGroup
)和实施可检查
。因此,当的ListView
设置为选择模式,它可以自动检查/取消这一观点。这选中状态,然后使用选择
分配给这种观点的背景:
The list item layout's parent view, is a class extending LinearLayout
(can be any ViewGroup
) and implementing Checkable
. Hence, when ListView
is set to choice mode, it can automatically check/uncheck this view. This checked state is then used by selector
background assigned to this view :
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/checked"/>
<item android:drawable="@drawable/unchecked"/>
</selector>
这会自动列表项目视图变化的背景下,而无需在code列表项中选择,每次做手工。
This makes the background of list item view change automatically, without having to do it manually in code every time a list item is selected.
结果:
查看源文件code
其他几点:
滚动条可以移动到左侧。 匹配阴影颜色,或更多的填充的使用列表分隔可放置列表项和细节视图之间。 Scrollbar can be moved to left side. Use list dividers that match shadow color, or more padding can be placed between list items and detail view.