get AdapterView Child At Position - Android User Interface

Android examples for User Interface:View Child

Description

get AdapterView Child At Position

Demo Code


//package com.java2s;

import android.view.View;

import android.widget.AdapterView;

public class Main {
    public static View getChildAtPosition(AdapterView view, int position) {
        final int numVisibleChildren = view.getChildCount();
        final int firstVisiblePosition = view.getFirstVisiblePosition();

        for (int i = 0; i < numVisibleChildren; i++) {
            int positionOfView = firstVisiblePosition + i;
            if (positionOfView == position) {
                return view.getChildAt(i);
            }// w  w w. ja v a  2s  .co m
        }
        return null;
    }
}

Related Tutorials