org.robolectric.shadows.ShadowListView Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of shadows-framework Show documentation
Show all versions of shadows-framework Show documentation
An alternative Android testing framework.
package org.robolectric.shadows;
import android.view.View;
import android.widget.HeaderViewListAdapter;
import android.widget.ListView;
import java.util.ArrayList;
import java.util.List;
import org.robolectric.annotation.Implements;
import org.robolectric.annotation.RealObject;
@SuppressWarnings({"UnusedDeclaration"})
@Implements(ListView.class)
public class ShadowListView extends ShadowAbsListView {
@RealObject private ListView realListView;
public List getHeaderViews() {
HeaderViewListAdapter adapter = (HeaderViewListAdapter) realListView.getAdapter();
ArrayList headerViews = new ArrayList<>();
int headersCount = adapter.getHeadersCount();
for (int i = 0; i < headersCount; i++) {
headerViews.add(adapter.getView(i, null, realListView));
}
return headerViews;
}
public List getFooterViews() {
HeaderViewListAdapter adapter = (HeaderViewListAdapter) realListView.getAdapter();
ArrayList footerViews = new ArrayList<>();
int offset = adapter.getHeadersCount() + adapter.getCount() - adapter.getFootersCount();
int itemCount = adapter.getCount();
for (int i = offset; i < itemCount; i++) {
footerViews.add(adapter.getView(i, null, realListView));
}
return footerViews;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy