下面列出了android.widget.ListView#getLocationOnScreen ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void findViewClicked(MotionEvent event, float eventY, ListView list) {
mChildCount = list.getChildCount();
mListViewCoords = new int[2];
list.getLocationOnScreen(mListViewCoords);
int x = (int) event.getRawX() - mListViewCoords[0];
int y = (int) event.getRawY() - mListViewCoords[1];
View child;
for (int i = 0; i < mChildCount; i++) {
child = list.getChildAt(i);
child.getHitRect(mRect);
if (mRect.contains(x, y)) {
mDownView = child;
mDownEventY = eventY;
break;
}
}
}
private void findViewClicked(MotionEvent event, float eventY, ListView list) {
mChildCount = list.getChildCount();
mListViewCoords = new int[2];
list.getLocationOnScreen(mListViewCoords);
int x = (int) event.getRawX() - mListViewCoords[0];
int y = (int) event.getRawY() - mListViewCoords[1];
View child;
for (int i = 0; i < mChildCount; i++) {
child = list.getChildAt(i);
child.getHitRect(mRect);
if (mRect.contains(x, y)) {
mDownView = child;
mDownEventY = eventY;
break;
}
}
}
private void findViewClicked(MotionEvent event, float eventY, ListView list) {
mChildCount = list.getChildCount();
mListViewCoords = new int[2];
list.getLocationOnScreen(mListViewCoords);
int x = (int) event.getRawX() - mListViewCoords[0];
int y = (int) event.getRawY() - mListViewCoords[1];
View child;
for (int i = 0; i < mChildCount; i++) {
child = list.getChildAt(i);
child.getHitRect(mRect);
if (mRect.contains(x, y)) {
mDownView = child;
mDownEventY = eventY;
break;
}
}
}