Example usage for android.widget ArrayAdapter addAll

List of usage examples for android.widget ArrayAdapter addAll

Introduction

In this page you can find the example usage for android.widget ArrayAdapter addAll.

Prototype

public void addAll(T... items) 

Source Link

Document

Adds the specified items at the end of the array.

Usage

From source file:org.bitbucket.ntakimura.android.support.fragment.OpenSourceLicenseFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    mLogger.entering(getClass().getName(), "onCreateView",
            new Object[] { inflater, container, savedInstanceState });

    FrameLayout lframe = new FrameLayout(getActivity());

    ListView lv = new ListView(getActivity());
    lv.setId(android.R.id.list);/*  w w  w. j ava2  s . c o  m*/
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    lframe.setBackgroundColor(getResources().getColor(android.R.color.background_light));

    ArrayAdapter<Parcelable> adapter = new SoftwareArrayAdapter(getActivity(), R.layout.card_item);
    if (getArguments() != null && getArguments().containsKey(EXTRA_OSS)) {
        adapter.addAll(getArguments().getParcelableArrayList(EXTRA_OSS));
    }

    ListView listView = (ListView) lframe.findViewById(android.R.id.list);
    listView.setAdapter(adapter);

    getDialog().setTitle(R.string.open_source_licenses);

    mLogger.exiting(getClass().getName(), "onCreateView", lframe);
    return lframe;
}

From source file:com.hardcopy.vcontroller.fragments.AddBrokerFragment.java

private void addAutoCompleteAdapter() {
    if (mAutoTextServer == null)
        return;//  w w  w . j a  va2 s  . co  m
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(mContext, android.R.layout.simple_list_item_1);
    adapter.addAll(Utils.getInstance(mContext).readSuggestion(Utils.AUTO_COMPLETE_SERVER));
    mAutoTextServer.setAdapter(adapter);
}

From source file:org.deviceconnect.android.manager.setting.OpenSourceLicenseFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    mLogger.entering(getClass().getName(), "onCreateView",
            new Object[] { inflater, container, savedInstanceState });

    FrameLayout lframe = new FrameLayout(getActivity());

    ListView lv = new ListView(getActivity());
    lv.setId(android.R.id.list);//from   w w  w . j a va 2  s. c  o  m
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    lframe.setBackgroundColor(getResources().getColor(android.R.color.background_light));

    ArrayAdapter<Parcelable> adapter = new SoftwareArrayAdapter(getActivity(),
            R.layout.item_open_source_licenses);
    if (getArguments() != null && getArguments().containsKey(EXTRA_OSS)) {
        adapter.addAll(getArguments().getParcelableArrayList(EXTRA_OSS));
    }

    ListView listView = (ListView) lframe.findViewById(android.R.id.list);
    listView.setAdapter(adapter);

    getDialog().setTitle(R.string.activity_settings_open_source_licenses);

    mLogger.exiting(getClass().getName(), "onCreateView", lframe);
    return lframe;
}

From source file:com.sandklef.coachapp.fragments.MemberFragment.java

public void updateMemberList() {
    Log.d(LOG_TAG, " updateMemberList() for team: " + LocalStorage.getInstance().getCurrentTeam());
    try {/*from w  w  w  .j  a v a2 s.  c o m*/
        ArrayAdapter<Member> ma = ((ArrayAdapter) mAdapter);
        ma.clear();
        List<Member> members = MemberFilterEngine.apply(Storage.getInstance().getMembers(),
                MemberTeamFilter.newMemberTeamFilter(LocalStorage.getInstance().getCurrentTeam()));

        ma.addAll(members);
        ma.notifyDataSetChanged();
    } catch (StorageNoClubException e) {
        e.printStackTrace();
    }
}

From source file:org.sufficientlysecure.keychain.ui.dialog.CreateKeyDialogFragment.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void replaceArrayAdapterContent(ArrayAdapter<CharSequence> arrayAdapter, int stringArrayResourceId) {
    final String[] spinnerValuesStringArray = getResources().getStringArray(stringArrayResourceId);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        arrayAdapter.addAll(spinnerValuesStringArray);
    } else {/*  ww  w  .j a v a2s . c  o m*/
        for (final String value : spinnerValuesStringArray) {
            arrayAdapter.add(value);
        }
    }
}

From source file:com.ferid.app.notetake.MainActivity.java

/**
 * Ask user to change font size/*from w ww .  ja va 2  s . c o  m*/
 */
private void changeFontSize() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(getString(R.string.fontSize));
    final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1);
    arrayAdapter.addAll(getResources().getStringArray(R.array.font_sizes));
    builder.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int which) {
            switch (which) {
            case 0:
                PrefsUtil.setFontSize(context, getResources().getInteger(R.integer.font_size_small));
                break;
            case 1:
                PrefsUtil.setFontSize(context, getResources().getInteger(R.integer.font_size_medium));
                break;
            case 2:
                PrefsUtil.setFontSize(context, getResources().getInteger(R.integer.font_size_large));
                break;
            default:
                PrefsUtil.setFontSize(context, getResources().getInteger(R.integer.font_size_medium));
                break;
            }

            setFontSize();
        }
    });
    AlertDialog alertDialog = builder.create();
    alertDialog.show();
}

From source file:org.gdg.frisbee.android.widget.FeedbackFragment.java

private void setupEmailAutocomplete() {
    //Set email AutoCompleteTextView
    ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.select_dialog_item);
    Set<String> accountsSet = new HashSet<>();
    Account[] deviceAccounts = AccountManager.get(getActivity()).getAccounts();
    for (Account account : deviceAccounts) {
        if (Utils.isEmailAddress(account.name)) {
            accountsSet.add(account.name);
        }/*from w ww.j a v a  2  s .  c  o m*/
    }
    adapter.addAll(accountsSet);
    mEmailField.setAdapter(adapter);
}

From source file:com.concentricsky.android.khanacademy.app.ManageDownloadsActivity.java

private void confirmAndDelete() {
    View contentView = getLayoutInflater().inflate(R.layout.dialog_confirm_delete, null, false);
    ListView list = (ListView) contentView.findViewById(R.id.dialog_confirm_delete_list);

    ArrayList<String> titles = new ArrayList<String>();
    final HashSet<Video> videos = new HashSet<Video>();

    SparseBooleanArray positions = gridView.getCheckedItemPositions();
    int n = positions.size();
    for (int i = 0; i < n; ++i) {
        Cursor c = (Cursor) gridView.getItemAtPosition(positions.keyAt(i));
        Video v = new Video();
        v.setReadable_id(c.getString(c.getColumnIndex("readable_id")));
        v.setYoutube_id(c.getString(c.getColumnIndex("youtube_id")));
        v.setDlm_id(c.getLong(c.getColumnIndex("dlm_id")));
        videos.add(v);//from  w ww.  j a va2 s . c  o  m
        titles.add(c.getString(c.getColumnIndex("title")));
    }

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.dialog_confirm_delete_item);
    adapter.addAll(titles);
    list.setAdapter(adapter);

    new AlertDialog.Builder(this).setView(contentView).setMessage(getString(R.string.msg_delete_videos))
            .setPositiveButton(getString(R.string.button_confirm_delete),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int id) {
                            deleteItems(videos);
                            if (actionMode != null) {
                                actionMode.finish();
                            }
                        }
                    })
            .setNegativeButton(getString(R.string.button_cancel), null).show();
}

From source file:com.vaquerosisd.projectmanager.NewTask.java

private void setSpinner(String spinnerFileName, ArrayAdapter<CharSequence> spinnerAdapter,
        Spinner spinnerObject, boolean sort) {
    String spinnerItems = fO.readFile(spinnerFileName);
    ArrayList<String> spinnerItemsArray = fO.convertToStringList(spinnerItems);
    if (sort)//w  w w .j a  v  a2s.co  m
        Collections.sort(spinnerItemsArray.subList(0, spinnerItemsArray.size()));

    //Set the adapter for the status spinner 
    spinnerAdapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item);
    spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinnerAdapter.addAll(spinnerItemsArray);
    spinnerObject.setAdapter(spinnerAdapter);
}

From source file:im.vector.fragments.ConsoleMessageListFragment.java

private void save(final Message message, final String mediaUrl, final String mediaMimeType) {
    AlertDialog.Builder builderSingle = new AlertDialog.Builder(getActivity());

    builderSingle.setTitle(getActivity().getText(R.string.save_files_in));
    final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getActivity(),
            R.layout.dialog_room_selection);

    ArrayList<String> entries = new ArrayList<String>();

    entries.add(getActivity().getText(R.string.downloads).toString());

    if ((null == mediaMimeType) || mediaMimeType.startsWith("image/")) {
        entries.add(getActivity().getText(R.string.gallery).toString());
    }//w ww .ja  va 2  s . c om

    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        entries.add(getActivity().getText(R.string.other).toString());
    }

    arrayAdapter.addAll(entries);

    final ArrayList<String> fEntries = entries;

    builderSingle.setNegativeButton(getActivity().getText(R.string.cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });

    builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, final int which) {
            dialog.dismiss();

            MXMediasCache cache = getMXMediasCache();
            File cacheFile = cache.mediaCacheFile(mediaUrl, mediaMimeType);

            String entry = fEntries.get(which);
            String savedFilename = null;

            if (getActivity().getText(R.string.gallery).toString().equals(entry)) {
                // save in the gallery
                savedFilename = CommonActivityUtils.saveImageIntoGallery(getActivity(), cacheFile);
            } else if (getActivity().getText(R.string.downloads).toString().equals(entry)) {
                String filename = null;

                if (message instanceof FileMessage) {
                    filename = ((FileMessage) message).body;
                }

                // save into downloads
                savedFilename = CommonActivityUtils.saveMediaIntoDownloads(getActivity(), cacheFile, filename,
                        mediaMimeType);
            } else {
                if (getActivity() instanceof RoomActivity) {
                    ((RoomActivity) getActivity()).createDocument(message, mediaUrl, mediaMimeType);
                }
            }

            if (null != savedFilename) {
                final String fSavedFilename = new File(savedFilename).getName();
                getActivity().runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(getActivity(),
                                getActivity().getString(R.string.file_is_saved, fSavedFilename),
                                Toast.LENGTH_SHORT).show();
                    }
                });
            }
        }
    });
    builderSingle.show();
}