Can you please tell me how can I create my own Preference class in andorid? with my own layout and own click listener?
Thank you.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, that’s about six or seven pages in a book, so it’s a bit involved for a StackOverflow answer. 🙂
Here is a sample project with a custom
View, which is also wrapped into a customPreference. It is only ~80 lines of code, though much of the UI smarts are bound up in the customViewclass.In a nutshell, to make a custom
DialogPreference, you need to define:onCreateDialogView()andonBindDialogView()to create the dialog contents and populate the contents with the preference dataonDialogClosed()to handle when the user changes the preferenceonGetDefaultValue()to handle your overall default if the preference is not yet setonSetInitialValue()to either load in the preference value or use your default