how to perfom smooth scrolling to a position without actually having to see the scrolling taking place in a listview?
I have made an Android application in which i have a ListView
and when the list view loads i wish to show the some middle portion of its adapter, hence i am using the smoothScrollTo
method in the Li开发者_运维百科stView
.
The problem with the above method is that i can see the scrolling take place, which i don't want.
I have tried putting a progressDialog when the scrolling is taking place , but i guess due to load on the UI thread, it never shows up. Hence hiding the scrolling taking place behind a progressdialog is out of the question.
I cannot even put the smoothscrolling code in another thread because only the UI thread can touch the UI elements.
How do i avoid the user from actually seeing the scrolling take place?
thank you in advance.
you can use ScrollTo(x,y) method of ListView instead of smoothScroll
This should make it work,
listView.setSelection(pos);
View v = listView.getChildAt(pos);
if (v != null)
{
v.requestFocus();
}
This work you can try this...
grd.requestFocusFromTouch();
grd.setSelection(adapter.getCount()-5);
grd.smoothScrollToPosition(adapter.getCount());
if don't work well you can delete first and second line
精彩评论