android - Programmatically set position in ListView without scrolling -


this tablet running android 4.4.2. have listview hundreds of items in , 20 visible @ time. user doesn't want animation of smooth scrolling. how programmatically set displayed position in listview without using smoothscrolltoposition()?

i searched stack overflow , in android listview setselection() not seem work suggested this:

mlistview.clearfocus(); mlistview.post(new runnable() {     @override     public void run() {         mlistview.setselection(index);     } }); 

. . . sets selection; not bring portion of listview view. setselection() seems popular solution on web couldn't find in documentation saying setselection() sets position, , sets selection , not change position on mine.

in go item in listview without using smoothscrolltoposition suggested solution romain guy ...

[mylistview.post(new runnable()  {     @override     public void run()      {         mylistview.setselection(pos);         view v = mylistview.getchildat(pos);         if (v != null)          {             v.requestfocus();         }     } });]  

the problem 1 listview part of listactivity being managed via custom adapter's getview(), views not visible recycled, i.e., if request child view of view that's not on screen returns null. anyway, it's listview i'm trying control, doing indirectly via child view seems awfully indirect.

how tell listview part of want visible on screen?

there method in abslistview, called smoothscrolltopositionfromtop() , takes duration parameter. if set 0, may without scrolling, animation.

smoothscrolltopositionfromtop.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -