2011-05-27 50 views
4

我試圖在ListView中以編程方式調用onScroll事件。Android:如何在ListView中以編程方式調用onScroll事件

任何人都可以幫助我嗎?

這裏我的代碼:

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

添加您正在使用的代碼... – Nallath 2011-05-27 12:39:08

回答

6

official documentation

public void smoothScrollByOffset (int offset) 

public void smoothScrollToPosition (int position) 
相關問題