Example usage for android.widget Adapter getView

List of usage examples for android.widget Adapter getView

Introduction

In this page you can find the example usage for android.widget Adapter getView.

Prototype

View getView(int position, View convertView, ViewGroup parent);

Source Link

Document

Get a View that displays the data at the specified position in the data set.

Usage

From source file:com.optimusinfo.elasticpath.cortex.common.Utils.java

@SuppressWarnings("rawtypes")
public static int getTotalHeightofListView(AdapterView argAdapterView) {
    Adapter mAdapter = argAdapterView.getAdapter();
    if (mAdapter == null) {
        // pre-condition
        return 0;
    }/*from ww  w .  j ava2s.  c  o m*/
    int totalHeight = 0;
    for (int i = 0; i < mAdapter.getCount(); i++) {
        View mView = mAdapter.getView(i, null, argAdapterView);
        mView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        mView.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
                MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
        totalHeight += mView.getMeasuredHeight();
    }
    return totalHeight;
}