Android Configuration Page Header

Asked 2 years ago, Updated 2 years ago, 120 views

https://developer.android.com/guide/topics/ui/settings.html You want to view this page and use a header file over the fragment.

In the header file creation sector,

<?xml version="1.0" encoding="utf-8"?>
<preference-headers xmlns:android="http://schemas.android.com/apk/res/android">
    <header
        android:fragment="com.example.prefs.SettingsActivity$SettingsFragmentOne"
        android:title="@string/prefs_category_one"
        android:summary="@string/prefs_summ_category_one" />
    <header
        android:fragment="com.example.prefs.SettingsActivity$SettingsFragmentTwo"
        android:title="@string/prefs_category_two"
        android:summary="@string/prefs_summ_category_two" >
        <!-- key/value pairs can be included as arguments for the fragment. -->
        <extra android:name="someKey" android:value="someHeaderValue" />
    </header>
</preference-headers>

Q1. Among the header sources, fragment="com.example.prefs.SettingsActivity$SettingsFragmentOne" is a red line in SettingsFragmentOne. Even if I make a fragment file and create a fragment, the red line doesn't disappear. How do we solve this?

android header

2022-09-22 21:29

1 Answers

I think it's better to check again if there's anything missing. My test code works well, so I think I missed something while writing the code. There is a code using the Preference API in Github below. I think it would be good to review it again by following from XML to Java code one by one.

preference_headers.xml

PreferenceWithHeaders$Prefs1Fragment

PreferenceWithHeaders$Prefs1Fragment


2022-09-22 21:29

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.