I have a PreferenceScreen, where the user can check/uncheck a checkbox.
To get access any Control in the Activity I used always:
var button = FindViewById<Button>(Resource.Id.myButton);
Well now, I want to access my CheckBoxPreference
..
, but its not working and I get this Exception:
The type 'Android.Preferences.CheckBoxPreference' cannot be used as type parameter 'T' in the generic type or method 'Android.App.Activity.FindViewById(int)'. There is no implicit reference conversion from 'Android.Preferences.CheckBoxPreference' to 'Android.Views.View'.
How my PreferenceScreen.xml looks like:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="Basic"
android:id="@+id/preferenceCategory">
<CheckBoxPreference
android:id="@+id/preferenceCheckBox"
android:key="usetestdata"
android:title="Testdata ON/OFF"
android:defaultValue="true" />
</PreferenceCategory>
</PreferenceScreen>
and the not working code:
var aCheckBox = FindViewById<CheckBoxPreference>(Resource.Id.preferenceCheckBox);
aCheckBox.Enabled = false;
Maybe someone can help me and tell me on how to access controls within an activity from a PreferenceScreen?