Code example for ListView

Methods: getAdapter, getView, performItemClick

0
    } 
 
    public ActionAssertion<?> click(final int position) {
        return AssertionResolver.actionAssertion(this, testCase, activity, new Runnable() {
            public void run() { 
                View itemView = getAdapter().getView(position, null, listView);
                assertNotNull("item view at position " + position + " was null", itemView);
                listView.performItemClick(itemView, position, itemView.getId());
            } 
        }, true); 
    } 
 
    public ActionAssertion<?> clickFirst() { 
        return click(0); 
    } 
 
    public ActionAssertion<?> clickLast() { 
        return click(getAdapter().getCount() - 1);
    } 
 
    private ListAdapter getAdapter() {
        ListAdapter adapter = listView.getAdapter();
        assertNotNull("list adapter expected to exist, but was null", adapter);
        return adapter;
    } 
}