Search in sources :

Example 6 with ListAdapter

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

the class ListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.list_activity);
    ListAdapter adapter = new SimpleListAdapter(this);
    ListView list = (ListView) findViewById(R.id.list);
    list.setAdapter(adapter);
    registerForContextMenu(list);
}
Also used : ListView(android.widget.ListView) ListAdapter(android.widget.ListAdapter)

Example 7 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 8 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)

Example 9 with ListAdapter

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

the class DynamicListView method swapElements.

private void swapElements(int indexOne, int indexTwo) {
    mLastMovedToIndex = indexTwo;
    ListAdapter adapter = getAdapter();
    if (adapter instanceof HeaderViewListAdapter) {
        adapter = ((HeaderViewListAdapter) adapter).getWrappedAdapter();
    }
    if (adapter instanceof Swappable) {
        ((Swappable) adapter).swapItems(indexOne - getHeaderViewsCount(), indexTwo - getHeaderViewsCount());
    }
}
Also used : HeaderViewListAdapter(android.widget.HeaderViewListAdapter) HeaderViewListAdapter(android.widget.HeaderViewListAdapter) ListAdapter(android.widget.ListAdapter)

Example 10 with ListAdapter

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

the class SwipeLayout method isEnabledInAdapterView.

/**
     * if working in {@link android.widget.AdapterView}, we should response {@link android.widget.Adapter}
     * isEnable(int position).
     * @return true when item is enabled, else disabled.
     */
private boolean isEnabledInAdapterView() {
    AdapterView adapterView = getAdapterView();
    boolean enable = true;
    if (adapterView != null) {
        Adapter adapter = adapterView.getAdapter();
        if (adapter != null) {
            int p = adapterView.getPositionForView(SwipeLayout.this);
            if (adapter instanceof BaseAdapter) {
                enable = ((BaseAdapter) adapter).isEnabled(p);
            } else if (adapter instanceof ListAdapter) {
                enable = ((ListAdapter) adapter).isEnabled(p);
            }
        }
    }
    return enable;
}
Also used : AdapterView(android.widget.AdapterView) Adapter(android.widget.Adapter) BaseAdapter(android.widget.BaseAdapter) ListAdapter(android.widget.ListAdapter) BaseAdapter(android.widget.BaseAdapter) ListAdapter(android.widget.ListAdapter)

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