Answer the question
In order to leave comments, you need to log in
How to make smoothScrollToPosition work in ListView more smoothly?
When scrolling the ListView, constantly changing the data in for the adapter
ListData.setListStrings(ListData.getListStringsAll().subList(fromPosition, toPosition));
Answer the question
In order to leave comments, you need to log in
There are two approaches. Perhaps they will help you.
1. Try to display the data not immediately, but by placing it in the queue of the UI thread:
public View getView( final int i, final View convertView, final ViewGroup parent ){
View row;
if( convertView == null ){
// creating
} else{
row = convertView;
}
final SomeClass idOfDataCell;
final SomeClass2 data;
final SomeView dataView = (SomeView)row.findViewById( R.id.id );
// init idOfDataCell, data
row.setTag( idOfDataCell );
row.post( new Runnable (){
@Override public void run ( ) {
if( dataView.getTag().equals( idOfDataCell )){
dataView.setData( data );
}
}
});
return row;
}
SomeAdapter adapter = new SomeAdapter();
listView.setOnScrollListener( new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged ( AbsListView view,int scrollState ){
if( scrollState == 2 ){
realtyListAdapter.scrolling( true );
} else{
realtyListAdapter.scrolling( false );
realtyListAdapter.notifyDataSetChanged();
}
}
} );
listView.setAdapter( adapter );
class SomeAdapter extends BaseAdapter {
private boolean scrolling;
public void scrolling( boolean scrolling ){
this.scrolling = scrolling;
}
@Override
public View getView( final int position, final View convertView, final ViewGroup parent ){
if( scrolling ) /* отобразить часть данных */;
else /* отобразить все данные */ ;
return null;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question