Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: How to invoke programmatically onScroll event in ListView

I am trying to invoke programmatically onScroll event in ListView.

Can anybody help me?

Here my code:

@RunWith(RobolectricTestRunner.class)
public class ActivityListViewTest {

    private ActivityListView activity;

    @Before
    public void setUp() throws Exception {
        activity = new ActivityListView();
    }

    @Test
    public void shouldUpdateListViewChildCountOnCreate() throws Exception{
        activity.onCreate(null);
        ListView calendarListView = (ListView)activity.findViewById(R.id.listview);

        assertTrue("CHILD COUNT IS: " + calendarListView.getChildCount(), calendarListView.getChildCount() > 0);

        // Here i want to invoke onScroll event. Then ListView must update and listView items count become to be more that 20

        assertTrue("CHILD COUNT IS: " + calendarListView.getChildCount(), calendarListView.getChildCount() > 20);
    }
}
like image 628
ihrupin Avatar asked May 27 '11 12:05

ihrupin


1 Answers

From the official documentation:

public void smoothScrollByOffset (int offset) 

or

public void smoothScrollToPosition (int position) 
like image 193
Gabriel Negut Avatar answered Sep 27 '22 17:09

Gabriel Negut