Search in sources :

Example 61 with ListAdapter

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);
        }
    }
}
Also used : CompletionInfo(android.view.inputmethod.CompletionInfo) InputMethodManager(android.view.inputmethod.InputMethodManager) ListAdapter(android.widget.ListAdapter) SuppressLint(android.annotation.SuppressLint)

Example 62 with ListAdapter

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;
}
Also used : ExpandableListAdapter(android.widget.ExpandableListAdapter) SectionIndexer(android.widget.SectionIndexer) ExpandableListAdapter(android.widget.ExpandableListAdapter) ListAdapter(android.widget.ListAdapter) WrapperListAdapter(android.widget.WrapperListAdapter) WrapperListAdapter(android.widget.WrapperListAdapter)

Example 63 with ListAdapter

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);
}
Also used : ListView(android.widget.ListView) Button(android.widget.Button) ListAdapter(android.widget.ListAdapter)

Example 64 with ListAdapter

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();
        }
    }
}
Also used : ViewGroup(android.view.ViewGroup) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) HeaderViewListAdapter(android.widget.HeaderViewListAdapter) ListAdapter(android.widget.ListAdapter)

Example 65 with ListAdapter

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;
}
Also used : HeaderViewListAdapter(android.widget.HeaderViewListAdapter) ListAdapter(android.widget.ListAdapter)

Aggregations

ListAdapter (android.widget.ListAdapter)298 ListView (android.widget.ListView)105 View (android.view.View)96 AdapterView (android.widget.AdapterView)55 AbsListView (android.widget.AbsListView)48 WrapperListAdapter (android.widget.WrapperListAdapter)47 HeaderViewListAdapter (android.widget.HeaderViewListAdapter)44 TextView (android.widget.TextView)42 ViewGroup (android.view.ViewGroup)37 Paint (android.graphics.Paint)22 ArrayAdapter (android.widget.ArrayAdapter)21 Point (android.graphics.Point)19 SuppressLint (android.annotation.SuppressLint)16 SimpleCursorAdapter (android.widget.SimpleCursorAdapter)16 Cursor (android.database.Cursor)12 SectionIndexer (android.widget.SectionIndexer)11 DialogInterface (android.content.DialogInterface)10 Bundle (android.os.Bundle)10 FrameLayout (android.widget.FrameLayout)10 GridView (android.widget.GridView)10