get ListView Child At Position - Android User Interface

Android examples for User Interface:ListView

Description

get ListView Child At Position

Demo Code


//package com.java2s;

import android.view.View;

import android.widget.ListView;

public class Main {
    public static View getChildAtPosition(ListView listView, int position) {
        int firstPostion = listView.getFirstVisiblePosition();
        int lastPostion = listView.getLastVisiblePosition();

        if ((position < firstPostion) || (position > lastPostion)) {
            return null;
        }/*from  w  w w.  ja v a 2  s .  c o m*/

        return listView.getChildAt(position - firstPostion
                + listView.getHeaderViewsCount());
    }
}

Related Tutorials