Java Code Examples for android.widget.ListView#getLocationOnScreen()

The following examples show how to use android.widget.ListView#getLocationOnScreen() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
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;
        }
    }
}
 
Example 2
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;
        }
    }
}
 
Example 3
Source Project: ListBuddies   File: ListBuddiesLayout.java    License: Apache License 2.0 6 votes vote down vote up
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;
        }
    }
}