get Adapter View - Android android.widget

Android examples for android.widget:Adapter

Description

get Adapter View

Demo Code

import android.util.SparseArray;
import android.view.View;

public class Main{


    @SuppressWarnings("unchecked")
    public static <T extends View> T getAdapterView(View convertView, int id) {
        SparseArray<View> viewHolder = (SparseArray<View>) convertView
                .getTag();//  w  w  w  .  jav 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