Code example for ListView

Methods: getChildAt, getSelectedItemPosition

0
    } 
 
    @LargeTest 
    public void testClickingHeaderWhenOtherItemHasFocusGivesHeaderFocus() { 
        sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
        assertEquals("selected position", 1, mListView.getSelectedItemPosition());
        TouchUtils.clickView(this, mListView.getChildAt(0));
        assertTrue("header has focus", mListView.getChildAt(0).isFocused());        
        assertEquals("nothing selected", AbsListView.INVALID_POSITION, mListView.getSelectedItemPosition());
    } 
}