Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

programmatically scroll PreferenceActivity

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?

like image 623
Mojo Risin Avatar asked Feb 11 '26 09:02

Mojo Risin


1 Answers

I know this is an old answered question, but I found a better way than iterating through all the categories.

PreferenceCategory myCat = (PreferenceCategory) findPreference("myKey");
int position = myCat.getOrder();
getListView().setSelection(position);
like image 104
Ryan Avatar answered Feb 15 '26 03:02

Ryan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!