2011-05-27 5 views
4

J'essaie d'appeler par programmation l'événement onScroll dans ListView.Android: Comment invoquer un événement onScroll par programmation dans ListView

Quelqu'un peut-il m'aider?

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

Ajoutez le code que vous utilisez ... – Nallath

Répondre

6

De l'official documentation:

public void smoothScrollByOffset (int offset) 

ou

public void smoothScrollToPosition (int position) 
Questions connexes