use of android.widget.ListAdapter in project HoloEverywhere by Prototik.
the class AutoCompleteTextView method buildImeCompletions.
private void buildImeCompletions() {
final ListAdapter adapter = mAdapter;
if (adapter != null) {
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
final int count = Math.min(adapter.getCount(), 20);
CompletionInfo[] completions = new CompletionInfo[count];
int realCount = 0;
for (int i = 0; i < count; i++) {
if (adapter.isEnabled(i)) {
Object item = adapter.getItem(i);
long id = adapter.getItemId(i);
completions[realCount] = new CompletionInfo(id, realCount, convertSelectionToString(item));
realCount++;
}
}
if (realCount != count) {
CompletionInfo[] tmp = new CompletionInfo[realCount];
System.arraycopy(completions, 0, tmp, 0, realCount);
completions = tmp;
}
imm.displayCompletions(this, completions);
}
}
}
use of android.widget.ListAdapter in project HoloEverywhere by Prototik.
the class FastScroller method getSectionsFromIndexer.
void getSectionsFromIndexer() {
ListAdapter adapter = mList.getAdapter();
mSectionIndexer = null;
if (adapter instanceof HeaderViewListAdapter) {
mListOffset = ((HeaderViewListAdapter) adapter).getHeadersCount();
}
if (adapter instanceof ListAdapterWrapper) {
adapter = ((ListAdapterWrapper) adapter).getWrappedAdapter();
}
if (adapter instanceof WrapperListAdapter) {
adapter = ((WrapperListAdapter) adapter).getWrappedAdapter();
}
if (adapter instanceof ExpandableListConnector) {
ExpandableListAdapter expAdapter = ((ExpandableListConnector) adapter).getAdapter();
if (expAdapter instanceof SectionIndexer) {
mSectionIndexer = (SectionIndexer) expAdapter;
mListAdapter = adapter;
mSections = mSectionIndexer.getSections();
}
} else {
if (adapter instanceof SectionIndexer) {
mSectionIndexer = (SectionIndexer) adapter;
mSections = mSectionIndexer.getSections();
if (mSections == null) {
mSections = new String[] { " " };
}
} else {
mSections = new String[] { " " };
}
}
mListAdapter = adapter;
}
use of android.widget.ListAdapter in project android_frameworks_base by ParanoidAndroid.
the class ListWithHeaders method onCreate.
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
final ListView listView = getListView();
listView.setItemsCanFocus(true);
for (int i = 0; i < 12; i++) {
Button header = new Button(this);
header.setText("Header View");
listView.addHeaderView(header);
}
for (int i = 0; i < 12; i++) {
Button footer = new Button(this);
footer.setText("Footer View");
listView.addFooterView(footer);
}
final ListAdapter adapter = listView.getAdapter();
listView.setAdapter(adapter);
}
use of android.widget.ListAdapter in project KeepScore by nolanlawson.
the class DragSortListView method getItemHeight.
private int getItemHeight(int position) {
final int first = getFirstVisiblePosition();
final int last = getLastVisiblePosition();
if (position >= first && position <= last) {
return getChildAt(position - first).getHeight();
} else {
//Log.d("mobeta", "getView for height");
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];
}
View v;
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);
}
ViewGroup.LayoutParams lp = v.getLayoutParams();
final int height = lp == null ? 0 : lp.height;
if (height > 0) {
return height;
} else {
int spec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
v.measure(spec, spec);
return v.getMeasuredHeight();
}
}
}
use of android.widget.ListAdapter in project UltimateAndroid by cymcsg.
the class DynamicListView method updateNeighborViewsForId.
/**
* Stores a reference to the views above and below the item currently
* corresponding to the hover cell. It is important to note that if this
* item is either at the top or bottom of the list, mAboveItemId or mBelowItemId
* may be invalid.
*/
private void updateNeighborViewsForId(long itemId) {
int position = getPositionForId(itemId);
ListAdapter adapter = getAdapter();
if (!adapter.hasStableIds()) {
throw new IllegalStateException("Adapter doesn't have stable ids! Make sure your adapter has stable ids, and override hasStableIds() to return true.");
}
mAboveItemId = position - 1 >= 0 ? adapter.getItemId(position - 1) : INVALID_ROW_ID;
mBelowItemId = position + 1 < adapter.getCount() ? adapter.getItemId(position + 1) : INVALID_ROW_ID;
}
Aggregations