I have PreferenceActivity with plenty of PreferenceCategories defined in it. If I have the android:key of a given category.
Is it possible programmatically to scroll the Activity to this category?
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.
You can iterate through the preferences in the activity like this:
Tested out with Android SDK 14 and it works fine.
Caution though, calling
getListView().setSelection(i)inside onCreate or onResume has no effect. It has to be called after the activity is drawn.The getPreferenceCount() method counts all PreferenceCategories and their nested preferences. Not sure what it does for PreferenceScreens, although I’m sure a little experimentation there would be revealing.