RichSz
Not Entitled
I'm a C++ programmer working my way through my first app and I've run into a wall. I'm sure there is a very simple solution to this but my lack of experience is hobbling me.
I have a preferences Activity which contains a CheckboxPreference controlling whether the app uses the vibrator or not. If the device running the app does not have a vibrator, I'd like this to be disabled (greyed out). I've defined the checkbox in XML and given it an ID.
When the preference Activity's onCreate is executed, I plan on making a check if the device has a vibrator and enabling/disabling the Checkbox accordingly.
The problem is I can't seem to get a reference to the actual Checkbox. I can read its state easily enough but can't figure out how to get the reference to the object via R.whatever. I want to learn this the right way by using XML wherever possible and not just new up a Checkbox and add it to the preferences Activity as a SharedPreference.
Can anyone help a noob out?
On a side note, why does the SDK reference believe there is a hasVibrator() method (Vibrator | Android Developers), yet Eclipse staunchly disagrees?
I have a preferences Activity which contains a CheckboxPreference controlling whether the app uses the vibrator or not. If the device running the app does not have a vibrator, I'd like this to be disabled (greyed out). I've defined the checkbox in XML and given it an ID.
Code:
<CheckBoxPreference
android:key="vibrateEnable"
android:summaryOn="@string/prefVibeEnabledSummary"
android:summaryOff="@string/prefVibeDisabledSummary"
android:disableDependentsState="false"
android:title="@string/titleVibEnablePref"
android:id="@+id/vibPrefEnable"/>
The problem is I can't seem to get a reference to the actual Checkbox. I can read its state easily enough but can't figure out how to get the reference to the object via R.whatever. I want to learn this the right way by using XML wherever possible and not just new up a Checkbox and add it to the preferences Activity as a SharedPreference.
Can anyone help a noob out?
On a side note, why does the SDK reference believe there is a hasVibrator() method (Vibrator | Android Developers), yet Eclipse staunchly disagrees?
