5

我正在尝试 onScroll在 ListView 中以编程方式调用事件。

有谁能够帮助我?

这是我的代码:

@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);
    }
}
4

1 回答 1

6

官方文档

public void smoothScrollByOffset (int offset) 

或者

public void smoothScrollToPosition (int position) 
于 2011-05-27T12:45:05.717 回答