Java Code Examples for android.widget.AdapterView#getChildAt()

The following examples show how to use android.widget.AdapterView#getChildAt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HeaderScrollHelper.java    From RichWebList with Apache License 2.0 5 votes vote down vote up
private boolean isAdapterViewTop(AdapterView adapterView) {
    if (adapterView != null) {
        int firstVisiblePosition = adapterView.getFirstVisiblePosition();
        View childAt = adapterView.getChildAt(0);
        if (childAt == null || (firstVisiblePosition == 0 && childAt.getTop() == 0)) {
            return true;
        }
    }
    return false;
}
 
Example 2
Source File: ScrollableHelper.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
private static boolean isAdapterViewTop(AdapterView adapterView) {
    if (adapterView != null) {
        int firstVisiblePosition = adapterView.getFirstVisiblePosition();
        View childAt = adapterView.getChildAt(0);
        return childAt == null || (firstVisiblePosition == 0 && childAt.getTop() == 0);
    }
    return false;
}
 
Example 3
Source File: ScrollableHelper.java    From ScrollableLayout with Apache License 2.0 5 votes vote down vote up
private static boolean isAdapterViewTop(AdapterView adapterView) {
    if (adapterView != null) {
        int firstVisiblePosition = adapterView.getFirstVisiblePosition();
        View childAt = adapterView.getChildAt(0);
        if (childAt == null || (firstVisiblePosition == 0 && childAt != null && childAt.getTop() == 0)) {
            return true;
        }
    }
    return false;
}
 
Example 4
Source File: AbsRefreshLayout.java    From NestRefreshLayout with MIT License 5 votes vote down vote up
private boolean canListScroll(int direction) {
    AdapterView<?> absListView = (AdapterView<?>) mTargetView;
    final int itemCount = absListView.getCount();
    final int childCount = absListView.getChildCount();
    final int firstPosition = absListView.getFirstVisiblePosition();
    final int lastPosition = firstPosition + childCount;

    if (itemCount == 0) {
        return false;
    }
    if (direction > 0) {
        // Are we already showing the entire last item?
        if (lastPosition >= itemCount) {
            final View lastView = absListView.getChildAt(childCount - 1);
            if (lastView != null
                    && lastView.getBottom() >= mTargetView.getHeight()) {
                return false;
            }
        }
    } else if (direction < 0) {
        // Are we already showing the entire first item?
        if (firstPosition <= 0) {
            final View firstView = absListView.getChildAt(0);
            if (firstView != null && firstView.getTop() >= 0) {
                return false;
            }
        }
    }
    return true;
}
 
Example 5
Source File: ScrollableHelper.java    From ScrollableLayout with MIT License 5 votes vote down vote up
private static boolean isAdapterViewTop(AdapterView adapterView){
    if(adapterView != null){
        int firstVisiblePosition = adapterView.getFirstVisiblePosition();
        View childAt = adapterView.getChildAt(0);
        if(childAt == null || (firstVisiblePosition == 0 && childAt.getTop() == 0)){
            return true;
        }
    }
    return false;
}
 
Example 6
Source File: AdapterViewProtocols.java    From android-test with Apache License 2.0 5 votes vote down vote up
private boolean isElementFullyRendered(
    AdapterView<? extends Adapter> adapterView, int childAt) {
  View element = adapterView.getChildAt(childAt);
  // Occassionally we'll have to fight with smooth scrolling logic on our definition of when
  // there is extra scrolling to be done. In particular if the element is the first or last
  // element of the list, the smooth scroller may decide that no work needs to be done to scroll
  // to the element if a certain percentage of it is on screen. Ugh. Sigh. Yuck.

  return isDisplayingAtLeast(FULLY_RENDERED_PERCENTAGE_CUTOFF).matches(element);
}
 
Example 7
Source File: HomeACTIVITY.java    From ALLGO with Apache License 2.0 5 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    selectItem(position);
    if(!isActivity(position)){
     	for(int i=0;i<parent.getCount();i++){
      View v=parent.getChildAt(i);
      if (position == i) {
          v.setBackgroundColor(Color.GRAY);
      } else {
          v.setBackgroundColor(Color.TRANSPARENT);
      }
  }
    }
    }