How to hide a Preference in xml android?

36 views Asked by At

I should hide a preference in xml. Here is an example.

Instead of removing the entire functionality, I need to hide the second preference which is top_level_connected_devices as key in xml. I am using android 10.

    <PreferenceScreen
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:settings="http://schemas.android.com/apk/res-auto"
        android:key="top_level_settings">
    
          <Preference
                android:key="@string/category_key_wireless"
                android:title="@string/interface_settings"
                android:icon="@drawable/ic_settings_interface"
                android:order="-120"
                android:fragment="com.android.settings.InterfaceSettings"/>
    
       <Preference
            android:key="top_level_connected_devices"
            android:title="@string/connected_devices_dashboard_title"
            android:summary="@string/summary_placeholder"
            android:icon="@drawable/ic_homepage_connected_device"
            android:order="-110"
            android:fragment="com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment"
            settings:controller="com.android.settings.connecteddevice.TopLevelConnectedDevicesPreferenceController"/>
  </PreferenceScreen>
0

There are 0 answers