scroll new ListActivity with Espresso


How to click on item that i can’t see lit7.txt?

I can’t scroll MyListActivity with Espresso and click on particular item. I would like to click on lit7.txt item, but i can’t see it on the screen. I need to scroll down. But how?

screen image with MyListActivity(DirectoryViewer) and lit7.txt

I can click on “Browse…”


I can click on histo2.txt


But how to click on item that i can’t see lit7.txt?

So, I loading my ListActivity(DirectoryViewer)

protected void onLoad(){
        Intent intent  new Intent(this, DirectoryViewer.class);
        intent.putExtra(DirectoryViewer.ASSET_DIRECTORY_LOCATION, "books");
        startActivityForResult(intent, 1);}

DirectoryViewer is:

class DirectoryViewer extends ListActivity
    void onCreate(Bundle savedInstanceState) {
        String dirName  getIntent().getStringExtra(ASSET_DIRECTORY_LOCATION);
        List<ListItem> items  new ArrayList<ListItem>();
        items.add(new BrowseListItem(getString(R.string.my_browse)));//Browse...
        items.add(new HeaderItem(getString(R.string.myItems)));//ITEMS
        AssetManager am  getResources().getAssets();//files
        try {
            String[] topLevel  am.list(dirName);
            for (String folder : topLevel) {


I’d suggest looking into the onData method which allows you to interact with information in ListViews.

Answered By – Zurvæ

Leave a Comment