0
與samerid元素的總數,我試圖讓元素的個數與同樣擺脫Android的咖啡:沒有適配器視圖
的這裏How to get count of items with same ids which are not in adapter view並沒有幫助我的解決方案。
static int counter = 0;
public static Matcher<View> withIdAndDisplayed(final int id) {
Checks.checkNotNull(id);
return new TypeSafeMatcher<View>() {
@Override
public void describeTo(Description description) {
description.appendText("with item id: " + id);
}
@Override
public boolean matchesSafely(View view) {
if ((view.getId() == id) && (view.getGlobalVisibleRect(new Rect())
&& withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE).matches(view))){
counter++;
return true;
}
return false;
}
};
}