get Item Child View - Android User Interface

Android examples for User Interface:View Child

Description

get Item Child View

Demo Code


//package com.java2s;
import android.util.SparseArray;
import android.view.View;

public class Main {

    public static <T extends View> T getItemChildView(View convertView,
            int id) {
        SparseArray<View> viewHolder = (SparseArray<View>) convertView
                .getTag();//from   w  ww.  j  av  a  2s .  co  m
        if (viewHolder == null) {
            viewHolder = new SparseArray<View>();
            convertView.setTag(viewHolder);
        }
        View childView = viewHolder.get(id);
        if (childView == null) {
            childView = convertView.findViewById(id);
            viewHolder.put(id, childView);
        }
        return (T) childView;
    }
}

Related Tutorials