I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...
You can try this it give. you the solution for your problem.
ReplyDeletescrollView = (ScrollView) findViewById(R.id.scr);
contentView = (ViewGroup) findViewById(R.id.r2);
scrollView.setOnTouchListener(new ScrollPager(scrollView, contentView));
scrollView.post(new Runnable() {
public void run() {
scrollView.scrollTo(0, contentView.getPaddingTop());
}
});
for this you need the scroolerPager Class. get it here,
public class ScrollPager implements OnTouchListener
public ScrollPager(ScrollView aScrollView, ViewGroup aContentView)
{
mScrollView = aScrollView;
mContentView = aContentView;
scroller = new Scroller(mScrollView.getContext(), new OvershootInterpolator());
task = new Runnable()
{
public void run()
{
scroller.computeScrollOffset();
mScrollView.scrollTo(0, scroller.getCurrY());
if (!scroller.isFinished())
{
mScrollView.post(this);
}
}
};
}
According to the android developers visit the following link.
ReplyDeletehttp://developer.android.com/reference/android/widget/AbsListView.html#setOverScrollMode(int)
the doc says you have to use following method.
public void setOverScrollMode (int mode)