Code example for ListView

Methods: setId

0
    private ListView listView;
 
    @Before 
    public void setUp() throws Exception { 
        listActivity = new ListActivity();
        listView = new ListView(listActivity);
        listView.setId(android.R.id.list);
 
        content = new FrameLayout(listActivity);
        content.addView(listView);
 
        listActivity.setContentView(content);
    } 
 
    @Test 
    public void shouldSupportSettingAndGettingListAdapter(){ 
        ListAdapter adapter = new CountingAdapter(5);
        listActivity.setListAdapter(adapter);
 
        assertThat(listActivity.getListAdapter()).isNotNull();
    }