My preference is described in preferences.xml like this:

<EditTextPreference android:key="maxTempDegrees"
android:summary="Maximum temperature" android:title="Max Temp"
android:persistent="true" android:defaultValue="100"
android:inputType="numberDecimal"></EditTextPreference>

This behaves very nicely in the preferences view, only allowing the
user to enter valid decimal numbers.

However, when I call SharedPreferences.getFloat with the
"maxTempDegrees" key, it throws a ClassCastException. Beyond the
inputType key, how can I tell getFloat to parse the user input as a
long?

By the way, I did some experimentation and the only "get" method that
worked was getLong. I was hoping to use getString and parse it myself
but that's not an option either. How do people handle float
preferences?

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to