Question

I'd like set up something like RingtonePreference but for vibration patterns, ListPreference seems like a good place to start but does not allow inclusion of an onClick handler. How would I go about extending it to add one? Is that even possible? And where can I find the source code for ListPreference, maybe I could just copy it it and make the edits I need?

Was it helpful?

Solution

Its pretty easy actually. you can find the source of ListPreference at: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/1.5_r4/android/preference/ListPreference.java

as you can see in the source, you just need to overwrite onPrepareDialogBuilder and mess with the onClick section. Note that you'll have to do some editing since you can't use private instance variables, but there are getters and setters for each one so its pretty straightforward

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top