Search in sources :

Example 16 with ListAdapter

use of android.widget.ListAdapter in project android_frameworks_base by ResurrectionRemix.

the class CascadingMenuPopup method findParentViewForSubmenu.

/**
     * Attempts to find the view for the menu item that owns the specified
     * submenu.
     *
     * @param parentInfo info for the parent menu
     * @param submenu the submenu whose parent view should be obtained
     * @return the parent view, or {@code null} if one could not be found
     */
@Nullable
private View findParentViewForSubmenu(@NonNull CascadingMenuInfo parentInfo, @NonNull MenuBuilder submenu) {
    final MenuItem owner = findMenuItemForSubmenu(parentInfo.menu, submenu);
    if (owner == null) {
        // Couldn't find the submenu owner.
        return null;
    }
    // The adapter may be wrapped. Adjust the index if necessary.
    final int headersCount;
    final MenuAdapter menuAdapter;
    final ListView listView = parentInfo.getListView();
    final ListAdapter listAdapter = listView.getAdapter();
    if (listAdapter instanceof HeaderViewListAdapter) {
        final HeaderViewListAdapter headerAdapter = (HeaderViewListAdapter) listAdapter;
        headersCount = headerAdapter.getHeadersCount();
        menuAdapter = (MenuAdapter) headerAdapter.getWrappedAdapter();
    } else {
        headersCount = 0;
        menuAdapter = (MenuAdapter) listAdapter;
    }
    // Find the index within the menu adapter's data set of the menu item.
    int ownerPosition = AbsListView.INVALID_POSITION;
    for (int i = 0, count = menuAdapter.getCount(); i < count; i++) {
        if (owner == menuAdapter.getItem(i)) {
            ownerPosition = i;
            break;
        }
    }
    if (ownerPosition == AbsListView.INVALID_POSITION) {
        // Couldn't find the owner within the menu adapter.
        return null;
    }
    // Adjust the index for the adapter used to display views.
    ownerPosition += headersCount;
    // Adjust the index for the visible views.
    final int ownerViewPosition = ownerPosition - listView.getFirstVisiblePosition();
    if (ownerViewPosition < 0 || ownerViewPosition >= listView.getChildCount()) {
        // Not visible on screen.
        return null;
    }
    return listView.getChildAt(ownerViewPosition);
}
Also used : AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) HeaderViewListAdapter(android.widget.HeaderViewListAdapter) MenuItem(android.view.MenuItem) HeaderViewListAdapter(android.widget.HeaderViewListAdapter) ListAdapter(android.widget.ListAdapter) Nullable(android.annotation.Nullable)

Example 17 with ListAdapter

use of android.widget.ListAdapter in project UltimateAndroid by cymcsg.

the class FloatingActionButtonDemo method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.floating_action_button_demo);
    FloatingActionButton floatingActionButton = (FloatingActionButton) findViewById(R.id.button_floating_action);
    floatingActionButton.attachToListView(getListView());
    ListAdapter listAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.countries));
    getListView().setAdapter(listAdapter);
}
Also used : FloatingActionButton(com.marshalchen.common.ui.FloatingActionButtonWithListView.FloatingActionButton) ListAdapter(android.widget.ListAdapter) ArrayAdapter(android.widget.ArrayAdapter)

Example 18 with ListAdapter

use of android.widget.ListAdapter in project UltimateAndroid by cymcsg.

the class ActivityTransitionActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_transition_first);
    ListView list = (ListView) this.findViewById(R.id.listView);
    ListAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, _animationList);
    list.setAdapter(adapter);
    list.setOnItemClickListener(this);
}
Also used : ListView(android.widget.ListView) ListAdapter(android.widget.ListAdapter) ArrayAdapter(android.widget.ArrayAdapter)

Example 19 with ListAdapter

use of android.widget.ListAdapter in project UltimateAndroid by cymcsg.

the class DragSortListView 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;
    }
}
Also used : View(android.view.View) ListView(android.widget.ListView) Point(android.graphics.Point) ListAdapter(android.widget.ListAdapter)

Example 20 with ListAdapter

use of android.widget.ListAdapter in project zxing by zxing.

the class LoadPackagesAsyncTask method onPostExecute.

@Override
protected void onPostExecute(final List<AppInfo> results) {
    ListAdapter listAdapter = new ArrayAdapter<AppInfo>(activity, R.layout.app_picker_list_item, R.id.app_picker_list_item_label, results) {

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view = super.getView(position, convertView, parent);
            Drawable icon = results.get(position).getIcon();
            if (icon != null) {
                ((ImageView) view.findViewById(R.id.app_picker_list_item_icon)).setImageDrawable(icon);
            }
            return view;
        }
    };
    activity.setListAdapter(listAdapter);
}
Also used : ViewGroup(android.view.ViewGroup) Drawable(android.graphics.drawable.Drawable) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) ListAdapter(android.widget.ListAdapter) ArrayAdapter(android.widget.ArrayAdapter)

Aggregations

ListAdapter (android.widget.ListAdapter)441 View (android.view.View)151 ListView (android.widget.ListView)144 ViewGroup (android.view.ViewGroup)75 WrapperListAdapter (android.widget.WrapperListAdapter)72 TextView (android.widget.TextView)70 AdapterView (android.widget.AdapterView)68 AbsListView (android.widget.AbsListView)66 HeaderViewListAdapter (android.widget.HeaderViewListAdapter)47 Paint (android.graphics.Paint)32 Point (android.graphics.Point)30 ArrayAdapter (android.widget.ArrayAdapter)30 ImageView (android.widget.ImageView)25 ArrayList (java.util.ArrayList)24 SuppressLint (android.annotation.SuppressLint)23 FrameLayout (android.widget.FrameLayout)20 DialogInterface (android.content.DialogInterface)18 GridView (android.widget.GridView)17 BaseAdapter (android.widget.BaseAdapter)16 SimpleCursorAdapter (android.widget.SimpleCursorAdapter)16