These are the default attributes available (You can also view inherited attributes by expanding the Inherited XML Attributes
block in the android docs for DialogPreference
):
android:dialogIcon - The icon for the dialog.
android:dialogLayout - A layout to be used as the content View for the dialog.
android:dialogMessage - The message in the dialog.
android:dialogTitle - The title in the dialog.
android:negativeButtonText - The negative button text for the dialog.
android:positiveButtonText - The positive button text for the dialog.
So in order to use your own attributes you need to create your own Resource
file where you define Stylable
s for your DialogPreference
like:
Resource\Values\MyTimePreferenceAttrs.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="MyTimePreference">
<attr name="defaultValue" format="string"/>
</declare-styleable>
</resources>
Then in your AXML layout where you create your TimePreference view you need to add a namespace so that they can be resolved:
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:my="http://schemas.android.com/apk/res-auto" >
<PreferenceCategory android:title="@string/pref_foo" >
...
<Client.Android.TimePreference
my:defaultValue="12:00" />
...
</PreferenceCategory>
</PreferenceScreen>
Then in your constructor of TimePreference
you can get the value with something like:
var ta = context.ObtainStyledAttributes(attrs, Resource.Styleable.MyTimePreference);
var defaultValue = ta.GetString(Resource.Styleable.MyTimePreference_defaultValue);
ta.Recycle();
You also might have a problem with using capitalized namespace in your XML layout. However the classname stays Capitalized, so:
<client.android.TimePreference
...