Search in sources :

Example 96 with ListAdapter

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

the class ListManagedCursor method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Get a cursor with all people
    Cursor c = getContentResolver().query(Settings.System.CONTENT_URI, null, null, null, null);
    startManagingCursor(c);
    ListAdapter adapter = new SimpleCursorAdapter(this, // Use a template that displays a text view
    android.R.layout.simple_list_item_1, // Give the cursor to the list adatper
    c, // Map the NAME column in the people database to...
    new String[] { People.NAME }, // The "text1" view defined in the XML template
    new int[] { android.R.id.text1 });
    setListAdapter(adapter);
    getListView().setOnItemClickListener(this);
}
Also used : SimpleCursorAdapter(android.widget.SimpleCursorAdapter) Cursor(android.database.Cursor) ListAdapter(android.widget.ListAdapter)

Example 97 with ListAdapter

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

the class SyncActivityTooManyDeletes method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle extras = getIntent().getExtras();
    if (extras == null) {
        finish();
        return;
    }
    mNumDeletes = extras.getLong("numDeletes");
    mAccount = (Account) extras.getParcelable("account");
    mAuthority = extras.getString("authority");
    mProvider = extras.getString("provider");
    // the order of these must match up with the constants for position used in onItemClick
    CharSequence[] options = new CharSequence[] { getResources().getText(R.string.sync_really_delete), getResources().getText(R.string.sync_undo_deletes), getResources().getText(R.string.sync_do_nothing) };
    ListAdapter adapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_list_item_1, android.R.id.text1, options);
    ListView listView = new ListView(this);
    listView.setAdapter(adapter);
    listView.setItemsCanFocus(true);
    listView.setOnItemClickListener(this);
    TextView textView = new TextView(this);
    CharSequence tooManyDeletesDescFormat = getResources().getText(R.string.sync_too_many_deletes_desc);
    textView.setText(String.format(tooManyDeletesDescFormat.toString(), mNumDeletes, mProvider, mAccount.name));
    final LinearLayout ll = new LinearLayout(this);
    ll.setOrientation(LinearLayout.VERTICAL);
    final LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0);
    ll.addView(textView, lp);
    ll.addView(listView, lp);
    // TODO: consider displaying the icon of the account type
    //        AuthenticatorDescription[] descs = AccountManager.get(this).getAuthenticatorTypes();
    //        for (AuthenticatorDescription desc : descs) {
    //            if (desc.type.equals(mAccount.type)) {
    //                try {
    //                    final Context authContext = createPackageContext(desc.packageName, 0);
    //                    ImageView imageView = new ImageView(this);
    //                    imageView.setImageDrawable(authContext.getDrawable(desc.iconId));
    //                    ll.addView(imageView, lp);
    //                } catch (PackageManager.NameNotFoundException e) {
    //                }
    //                break;
    //            }
    //        }
    setContentView(ll);
}
Also used : ListView(android.widget.ListView) Bundle(android.os.Bundle) TextView(android.widget.TextView) ListAdapter(android.widget.ListAdapter) ArrayAdapter(android.widget.ArrayAdapter) LinearLayout(android.widget.LinearLayout)

Example 98 with ListAdapter

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

the class WatchHeaderListView method wrapAdapterIfNecessary.

private void wrapAdapterIfNecessary() {
    ListAdapter adapter = getAdapter();
    if (adapter != null && mTopPanel != null) {
        if (!(adapter instanceof WatchHeaderListAdapter)) {
            wrapHeaderListAdapterInternal();
        }
        ((WatchHeaderListAdapter) getAdapter()).setTopPanel(mTopPanel);
        dispatchDataSetObserverOnChangedInternal();
    }
}
Also used : HeaderViewListAdapter(android.widget.HeaderViewListAdapter) ListAdapter(android.widget.ListAdapter)

Example 99 with ListAdapter

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

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 100 with ListAdapter

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

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)

Aggregations

ListAdapter (android.widget.ListAdapter)295 ListView (android.widget.ListView)104 View (android.view.View)94 AdapterView (android.widget.AdapterView)54 AbsListView (android.widget.AbsListView)47 WrapperListAdapter (android.widget.WrapperListAdapter)47 HeaderViewListAdapter (android.widget.HeaderViewListAdapter)43 TextView (android.widget.TextView)41 ViewGroup (android.view.ViewGroup)36 Paint (android.graphics.Paint)21 ArrayAdapter (android.widget.ArrayAdapter)21 Point (android.graphics.Point)18 SuppressLint (android.annotation.SuppressLint)16 SimpleCursorAdapter (android.widget.SimpleCursorAdapter)16 Cursor (android.database.Cursor)12 DialogInterface (android.content.DialogInterface)10 Bundle (android.os.Bundle)10 FrameLayout (android.widget.FrameLayout)10 ImageView (android.widget.ImageView)10 SectionIndexer (android.widget.SectionIndexer)10