如何使用PreferenceFragmentCompat在首选项之间显示分隔线

时间:2019-01-06 14:50:22

标签: android android-layout

我创建了一个首选项屏幕,并在扩展PreferenceFragmentCompat的类中进行了充气。但是首选项之间的分隔线没有显示

2 个答案:

答案 0 :(得分:1)

如果使用 AndroidX ,请将以下属性添加到XML的每个首选项中:

<Preference
    ...
    app:allowDividerAbove="true"
    app:allowDividerBelow="true"
    ... />

您还可以在此处查看更详细的答案:here

答案 1 :(得分:0)

将每个“首选项”与“ PreferenceCategory”标记包装在一起,以获取XML文件中首选项之间的分隔符。

示例:

CREATE TEMPORARY TABLE CTE_ID AS
(
SELECT FULL_NAME, COUNT(DISTINCT ID) as ID_COUNT, MAX(ID) AS MAX_ID
FROM MEMBERS
GROUP BY FULL_NAME
HAVING COUNT(DISTINCT ID) > 1
);

UPDATE a
SET a.ID = b.MAX_ID
FROM MEMBERS a
INNER JOIN CTE_ID b
ON a.FULL_NAME = b.FULL_NAME