android app has long preference screens, open @ top of preference menu. have idea user wants in preference menu. how can force preference screen open scrolled specific preference item?
i know old one, answer reference.
to auto-select given screen, have setpreferencescreen()
(this pre-honeycomb non-fragment preferenceactivity).
once you're on correct preferencescreen, can indeed use getlistview().smoothscrolltoposition(position)
(but froyo+ method), or can use getlistview.setselection(position)
.
but how position?
first, watch out trap: preferenceactivity.getlistadapter()
not return actual listadapter, local instance variable disconcertingly not in sync preferenceactivity.getlistview().getadapter()
(and null).
second, trying use preference.getorder()
returns order of preference object within parent, want use position only if you're not using preferencecategories
since need order within preferencescreen.
if using preferencecategories, need iterate on items in adapter (for (int = 0; < adapter.getcount(); i++)
until find right one, , use position.
another corner of android sdk in dire need of attention…
Comments
Post a Comment