use of android.widget.ListAdapter in project Lazy by l123456789jy.
the class ViewUtils method getAbsListViewHeightBasedOnChildren.
/**
* get AbsListView height according to every children
*
* @param view view
* @return int
*/
public static int getAbsListViewHeightBasedOnChildren(AbsListView view) {
ListAdapter adapter;
if (view == null || (adapter = view.getAdapter()) == null) {
return 0;
}
int height = 0;
for (int i = 0; i < adapter.getCount(); i++) {
View item = adapter.getView(i, null, view);
if (item instanceof ViewGroup) {
item.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}
item.measure(0, 0);
height += item.getMeasuredHeight();
}
height += view.getPaddingTop() + view.getPaddingBottom();
return height;
}
use of android.widget.ListAdapter in project SmartAndroidSource by jaychou2012.
the class DragListView method getChildHeight.
private int getChildHeight(int position) {
if (position == mSrcPos) {
return 0;
}
View v = getChildAt(position - getFirstVisiblePosition());
if (v != null) {
// hence the "true"
return getChildHeight(position, v, false);
} else {
// item is offscreen
// first check cache for child height at this position
int childHeight = mChildHeightCache.get(position);
if (childHeight != -1) {
// Log.d("mobeta", "found child height in cache!");
return childHeight;
}
final ListAdapter adapter = getAdapter();
int type = adapter.getItemViewType(position);
// There might be a better place for checking for the following
final int typeCount = adapter.getViewTypeCount();
if (typeCount != mSampleViewTypes.length) {
mSampleViewTypes = new View[typeCount];
}
if (type >= 0) {
if (mSampleViewTypes[type] == null) {
v = adapter.getView(position, null, this);
mSampleViewTypes[type] = v;
} else {
v = adapter.getView(position, mSampleViewTypes[type], this);
}
} else {
// type is HEADER_OR_FOOTER or IGNORE
v = adapter.getView(position, null, this);
}
// current child height is invalid, hence "true" below
childHeight = getChildHeight(position, v, true);
// cache it because this could have been expensive
mChildHeightCache.add(position, childHeight);
return childHeight;
}
}
use of android.widget.ListAdapter in project SmartAndroidSource by jaychou2012.
the class Common method onScrollStateChanged2.
private void onScrollStateChanged2(AbsListView lv, int scrollState) {
lv.setTag(AQuery.TAG_NUM, scrollState);
if (scrollState == SCROLL_STATE_IDLE) {
int first = lv.getFirstVisiblePosition();
int last = lv.getLastVisiblePosition();
int count = last - first;
ListAdapter la = lv.getAdapter();
for (int i = 0; i <= count; i++) {
long packed = i + first;
View convertView = lv.getChildAt(i);
Number targetPacked = (Number) convertView.getTag(AQuery.TAG_NUM);
if (targetPacked != null) {
la.getView((int) packed, convertView, lv);
convertView.setTag(AQuery.TAG_NUM, null);
} else {
//AQUtility.debug("skip!");
}
}
}
}
use of android.widget.ListAdapter in project android-common by Trinea.
the class ViewUtils method getListViewHeightBasedOnChildren.
/**
* get ListView height according to every children
*
* @param view
* @return
*/
public static int getListViewHeightBasedOnChildren(ListView view) {
int height = getAbsListViewHeightBasedOnChildren(view);
ListAdapter adapter;
int adapterCount;
if (view != null && (adapter = view.getAdapter()) != null && (adapterCount = adapter.getCount()) > 0) {
height += view.getDividerHeight() * (adapterCount - 1);
}
return height;
}
use of android.widget.ListAdapter in project SeriesGuide by UweTrottmann.
the class HeaderGridView method addHeaderView.
/**
* Add a fixed view to appear at the top of the grid. If addHeaderView is called more than once,
* the views will appear in the order they were added. Views added using this call can take
* focus if they want. <p> NOTE: Call this before calling setAdapter. This is so HeaderGridView
* can wrap the supplied cursor with one that will also account for header views.
*
* @param v The view to add.
* @param data Data to associate with this view
* @param isSelectable whether the item is selectable
*/
public void addHeaderView(View v, Object data, boolean isSelectable) {
ListAdapter adapter = getAdapter();
if (adapter != null && !(adapter instanceof HeaderViewGridAdapter)) {
throw new IllegalStateException("Cannot add header view to grid -- setAdapter has already been called.");
}
FixedViewInfo info = new FixedViewInfo();
FrameLayout fl = new FullWidthFixedViewLayout(getContext());
fl.addView(v);
info.view = v;
info.viewContainer = fl;
info.data = data;
info.isSelectable = isSelectable;
mHeaderViewInfos.add(info);
// we need to notify the observer
if (adapter != null) {
((HeaderViewGridAdapter) adapter).notifyDataSetChanged();
}
}
Aggregations