Java Code Examples for android.widget.AdapterView#setAdapter()

The following examples show how to use android.widget.AdapterView#setAdapter() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Binds this adapter to the given {@link AdapterView}, setting it as its adapter. This should be done by
 * construction or immediately after, before this adapter is used. This mechanism sets this class as the view's
 * adapter and permits certain functionality such as click events. Without it, this class will still function as
 * a normal {@link BaseAdapter}, but additional functionality may not work. Ignore this step at your own risk.
 *
 * @param adapterView The {@link AdapterView} to bind to.
 */
public void bindToAdapterView(AdapterView<? super BaseAdapter> adapterView) {
    if (adapterView != null) {
        adapterView.setAdapter(this);

        // Spinners don't like on item click listeners.
        // We will still delegate calls to it since you're clicking on an item to select it...
        if (!(adapterView instanceof Spinner)) {
            adapterView.setOnItemClickListener(internalItemClickListener);
        } else {
            adapterView.setOnItemSelectedListener(internalItemSelectedListener);
        }

        adapterView.setOnItemLongClickListener(internalLongClickListener);
    }
}
 
Example 2
private void setupUIFromAdapter(AdapterView view) {
    view.setAdapter(adapter);
    if (view instanceof ListView) {
        EntitySelectViewSetup.setupDivider(this, (ListView)view, shortSelect.usesEntityTileView());
    }
    findViewById(R.id.entity_select_loading).setVisibility(View.GONE);
    entitySelectSearchUI.setSearchBannerState();
}
 
Example 3
@SuppressWarnings({ "rawtypes", "unchecked" })
private static void setAdapterProxy(final AdapterView adapterView) {
    Adapter adapter = adapterView.getAdapter();
    if (adapter == null || Proxy.isProxyClass(adapter.getClass())) {
        // Thou shalt not Proxy a Proxy!
        return;
    }
    if (adapterView instanceof ExpandableListView) {
        // FIXME - Right now, skip the support for ExpandableListView.
        // This class throws exceptions on setAdapter(Adapter), and requires
        // a special adapter that only works with it.... Lame API break!
        return;
    }
    // Collect the Adapter sub-interfaces that we
    // would like to proxy.
    List<Class<?>> interfaces = new ArrayList<Class<?>>(4);
    interfaces.add(Adapter.class);
    if (adapter instanceof ListAdapter) {
        interfaces.add(ListAdapter.class);
    }
    if (adapter instanceof WrapperListAdapter) {
        interfaces.add(WrapperListAdapter.class);
    }
    if (adapter instanceof SpinnerAdapter) {
        interfaces.add(SpinnerAdapter.class);
    }

    // Create a proxy for the adapter to intercept
    // the 'getView'
    Adapter newAdapter = (Adapter) PXAdapterInvocationHandler.newInstance(adapterView,
            interfaces.toArray(new Class<?>[interfaces.size()]));

    // Set the proxy as the adapter
    adapterView.setAdapter(newAdapter);
}
 
Example 4
public void setAdapterView(AdapterView<? super BaseAdapter> adapterView) {
    this.adapterView = adapterView;
    checkActivity();
    adapterView.setOnItemLongClickListener(this);
    adapterView.setOnItemClickListener(this);
    adapterView.setAdapter(owner);
    parseAttrs();

    if (!checkedItems.isEmpty()) {
        startActionMode();
        onItemSelectedStateChanged();
    }
}
 
Example 5
public ItemViewHelper setAdapter(int viewId, Adapter adapter) {
    AdapterView view = this.getView(viewId);
    view.setAdapter(adapter);
    return this;
}
 
Example 6
@Override
public void deliverLoadResult(List<Entity<TreeReference>> entities,
                              List<TreeReference> references,
                              NodeEntityFactory factory, int focusTargetIndex) {
    loader = null;

    AdapterView visibleView;
    if (shortSelect.shouldBeLaidOutInGrid()) {
        visibleView = ((GridView)this.findViewById(R.id.screen_entity_select_grid));
    } else {
        ListView listView = this.findViewById(R.id.screen_entity_select_list);
        EntitySelectViewSetup.setupDivider(this, listView, shortSelect.usesEntityTileView());
        visibleView = listView;
    }

    adapter = new EntityListAdapter(this, shortSelect, references, entities, factory,
            hideActionsFromEntityList, shortSelect.getCustomActions(evalContext()), inAwesomeMode);
    visibleView.setAdapter(adapter);
    adapter.registerDataSetObserver(this.mListStateObserver);
    containerFragment.setData(adapter);

    if (entitySelectSearchUI != null) {
        entitySelectSearchUI.restoreSearchString();
    }

    // Pre-select entity if one was provided in original intent
    if (!resuming && !mNoDetailMode && inAwesomeMode && this.getIntent().hasExtra(EXTRA_ENTITY_KEY)) {
        TreeReference entity = selectDatum.getEntityFromID(evalContext(),
                this.getIntent().getStringExtra(EXTRA_ENTITY_KEY));

        if (entity != null) {
            displayReferenceAwesome(entity, adapter.getPosition(entity));
            updateSelectedItem(entity, true);
        }
    }

    findViewById(R.id.entity_select_loading).setVisibility(View.GONE);

    if (adapter != null) {
        // filter by additional session data (search string, callout result data)
        // Relevant when user navigates so far forward in the session that
        // the entity list needs to be reloaded upon returning to it
        restoreAdapterStateFromSession();
    }

    if (inAwesomeMode) {
        updateSelectedItem(true);
    } else if (focusTargetIndex != -1) {
        visibleView.setSelection(focusTargetIndex);
    }

    refreshTimer.start(this);

    if (locationChangedWhileLoading) {
        Log.i("HereFunctionHandler", "location changed while reloading");
        locationChangedWhileLoading = false;
        loadEntities();
    }
}
 
Example 7
Source Project: imsdk-android   File: BaseViewHolder.java    License: MIT License 3 votes vote down vote up
/**
 * Sets the adapter of a adapter view.
 *
 * @param viewId  The view id.
 * @param adapter The adapter;
 * @return The BaseViewHolder for chaining.
 */
@SuppressWarnings("unchecked")
public BaseViewHolder setAdapter(@IdRes int viewId, Adapter adapter) {
    AdapterView view = getView(viewId);
    view.setAdapter(adapter);
    return this;
}
 
Example 8
Source Project: BaseProject   File: BaseViewHolder.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Sets the adapter of a adapter view.
 *
 * @param viewId  The view id.
 * @param adapter The adapter;
 * @return The BaseViewHolder for chaining.
 */
@SuppressWarnings("unchecked")
public BaseViewHolder setAdapter(@IdRes int viewId, Adapter adapter) {
    AdapterView view = getView(viewId);
    view.setAdapter(adapter);
    return this;
}
 
Example 9
Source Project: demo4Fish   File: BaseViewHolder.java    License: MIT License 2 votes vote down vote up
/**
 * Sets the adapter of a adapter view.
 *
 * @param viewId  The view id.
 * @param adapter The adapter;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setAdapter(int viewId, Adapter adapter) {
    AdapterView view = getView(viewId);
    view.setAdapter(adapter);
    return this;
}
 
Example 10
Source Project: GoogleVR   File: BaseViewHolder.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Sets the adapter of a adapter view.
 *
 * @param viewId  The view id.
 * @param adapter The adapter;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setAdapter(int viewId, Adapter adapter) {
    AdapterView view = getView(viewId);
    view.setAdapter(adapter);
    return this;
}
 
Example 11
Source Project: JD-Test   File: BaseViewHolder.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Sets the adapter of a adapter view.
 *
 * @param viewId  The view id.
 * @param adapter The adapter;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setAdapter(int viewId, Adapter adapter) {
    AdapterView view = getView(viewId);
    view.setAdapter(adapter);
    return this;
}
 
Example 12
/**
 * Sets the adapter of a adapter view.
 *
 * @param viewId  The view id.
 * @param adapter The adapter;
 * @return The BaseAdapterHelper for chaining.
 */
public BaseAdapterHelper setAdapter(int viewId, Adapter adapter) {
    AdapterView view = retrieveView(viewId);
    view.setAdapter(adapter);
    return this;
}
 
Example 13
Source Project: basic-adapter   File: BaseViewHolder.java    License: MIT License 2 votes vote down vote up
/**
 * Sets the adapter of a adapter view.
 *
 * @param viewId  The view id.
 * @param adapter The adapter;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setAdapter(int viewId, Adapter adapter) {
    AdapterView view = getView(viewId);
    view.setAdapter(adapter);
    return this;
}
 
Example 14
/**
 * Sets the adapter of a adapter view.
 *
 * @param viewId  The view id.
 * @param adapter The adapter;
 * @return The BaseAdapterHelper for chaining.
 */
public BaseAdapterHelper setAdapter(int viewId, Adapter adapter) {
    AdapterView view = retrieveView(viewId);
    view.setAdapter(adapter);
    return this;
}
 
Example 15
Source Project: AndroidBase   File: BaseAdapterHelper.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Sets the adapter of a adapter view.
 *
 * @param viewId
 *            The view id.
 * @param adapter
 *            The adapter;
 * @return The BaseAdapterHelper for chaining.
 */
public BaseAdapterHelper setAdapter(int viewId, Adapter adapter) {
    AdapterView view = retrieveView(viewId);
    view.setAdapter(adapter);
    return this;
}
 
Example 16
Source Project: AndroidBase   File: BaseViewHolder.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Sets the adapter of a adapter view.
 *
 * @param viewId  The view id.
 * @param adapter The adapter;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setAdapter(int viewId, Adapter adapter) {
    AdapterView view = getView(viewId);
    view.setAdapter(adapter);
    return this;
}
 
Example 17
Source Project: NIM_Android_UIKit   File: BaseViewHolder.java    License: MIT License 2 votes vote down vote up
/**
 * Sets the adapter of a adapter view.
 *
 * @param viewId  The view id.
 * @param adapter The adapter;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setAdapter(int viewId, Adapter adapter) {
    AdapterView view = getView(viewId);
    view.setAdapter(adapter);
    return this;
}
 
Example 18
/**
 * Sets the adapter of a adapter view.
 *
 * @param viewId  The view id.
 * @param adapter The adapter;
 * @return The BaseAdapterHelper for chaining.
 */
public BaseAdapterHelper setAdapter(int viewId, Adapter adapter) {
    AdapterView view = retrieveView(viewId);
    view.setAdapter(adapter);
    return this;
}