Reputation: 994
I am building preference activity using headers. In the documentation, I saw that extra
parameters can be specified per each header
entry. In the code, I'd like to access those extra values when building the header list within the settings activity as follows. Note that I am doing it from the activity which overloads onBuildHeaders
and not from the header fragment.
if (header.extras != null && header.extras.containsKey("someKey")) {
...
}
However, the extras parameter is always null. Is there a way for force it to be read in?
Upvotes: 1
Views: 716
Reputation: 4169
Add your extras in your header
like so:
<header android:title="Display" >
<extra
android:name="separator"
android:value="true" />
</header>
And then retrieve the value with the following:
boolean isSeparator = false;
Bundle extras = header.fragmentArguments;
if (extras != null)
{
isSeparator = extras.containsKey("separator");
}
Note that you want to use header.fragmentArguments
instead of the .extras
field.
Upvotes: 5