下面列出了android.widget.AdapterView#getChildAt ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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;
}
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;
}
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;
}
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;
}
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;
}
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);
}
@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);
}
}
}
}