Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在gridlayout中排列PreferenceActivity中的复选框?_Android_Android Preferences_Android Gridlayout - Fatal编程技术网

Android 如何在gridlayout中排列PreferenceActivity中的复选框?

Android 如何在gridlayout中排列PreferenceActivity中的复选框?,android,android-preferences,android-gridlayout,Android,Android Preferences,Android Gridlayout,我到处都找到了,但找不到正确的解决方案 我有一个首选项活动,每个元素都有一个默认布局。在我的作品中,有两种偏好类别,一种是ListPreference,另一种是CheckBoxPreference 我知道如何设置每个元素的自定义布局。i、 e我已成功应用自定义复选框但我希望复选框在3X3网格中,而不是在listview中。 这是xml文件 <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android

我到处都找到了,但找不到正确的解决方案

我有一个首选项活动,每个元素都有一个默认布局。在我的作品中,有两种偏好类别,一种是ListPreference,另一种是CheckBoxPreference

我知道如何设置每个元素的自定义布局。i、 e我已成功应用自定义复选框但我希望复选框在3X3网格中,而不是在listview中。

这是xml文件

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
    >

    <PreferenceCategory android:title="Location Filter" >
        <ListPreference
            android:defaultValue="-1"
            android:entries="@array/location"
            android:entryValues="@array/locationvalues"
            android:key="locationfilter"
            android:negativeButtonText="@null"
            android:positiveButtonText="@null"
            android:summary="Value"
            android:title="Display results for" />
    </PreferenceCategory>
    <PreferenceCategory android:title="Category" 
        >
        <CheckBoxPreference
            android:defaultValue="true"
            android:key="key_one"
            android:layout="@layout/checkboxlayout"
            android:title="Cat 1" >
        </CheckBoxPreference>
        <CheckBoxPreference
            android:defaultValue="true"
            android:key="key_two"
            android:layout="@layout/checkboxlayout"
            android:title="Cat 2" >
        </CheckBoxPreference>
        <CheckBoxPreference
            android:defaultValue="true"
            android:key="key_three"
            android:layout="@layout/checkboxlayout"
            android:title="Cat 3" >
        </CheckBoxPreference>
        <CheckBoxPreference
            android:defaultValue="true"
            android:key="key_four"
            android:layout="@layout/checkboxlayout"
            android:title="Cat 4" >
        </CheckBoxPreference>
        <CheckBoxPreference
            android:defaultValue="true"
            android:key="key_five"
            android:layout="@layout/checkboxlayout"
            android:title="Cat 5" >
        </CheckBoxPreference>
        <CheckBoxPreference
            android:defaultValue="true"
            android:key="key_six"
            android:layout="@layout/checkboxlayout"
            android:title="Cat 6" >
        </CheckBoxPreference>
        <CheckBoxPreference
            android:defaultValue="true"
            android:key="key_seven"
            android:layout="@layout/checkboxlayout"
            android:title="Cat 7" >
        </CheckBoxPreference>
    </PreferenceCategory>

</PreferenceScreen>

我有一张图片来解释这个场景。
提前谢谢

我给了你一张投票,你可以添加一张图片。谢谢!添加了图像。