Search in sources :

Example 26 with ListAdapter

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

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

use of android.widget.ListAdapter in project cw-omnibus by commonsguy.

the class LoremSearch method makeMeAnAdapter.

@Override
ListAdapter makeMeAnAdapter(Intent intent) {
    ListAdapter adapter = null;
    if (intent.getAction().equals(Intent.ACTION_SEARCH)) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        List<String> results = searchItems(query);
        adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, results);
        setTitle("LoremSearch for: " + query);
    }
    return (adapter);
}
Also used : ListAdapter(android.widget.ListAdapter)

Example 28 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 29 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 30 with ListAdapter

use of android.widget.ListAdapter in project weex-example by KalicyZhou.

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