Example usage for android.widget ArrayAdapter setDropDownViewResource

List of usage examples for android.widget ArrayAdapter setDropDownViewResource

Introduction

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

Prototype

public void setDropDownViewResource(@LayoutRes int resource) 

Source Link

Document

Sets the layout resource to create the drop down views.

Usage

From source file:com.billooms.harppedals.chords.ChordFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    //      Log.d(TAG, "ChordFragment.onCreateView");
    View view = inflater.inflate(R.layout.fragment_chord, container, false);

    rootSpinner = (Spinner) view.findViewById(R.id.rootSpinner);
    List<String> rootList = new ArrayList<>();
    for (BasicNote n : BasicNote.values()) {
        rootList.add(n.name());/*from w ww. jav a2  s  .  c  o m*/
    }
    ArrayAdapter rootAdapter = new ArrayAdapter<>(this.getContext(), R.layout.spinner_item, rootList);
    rootAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    rootSpinner.setAdapter(rootAdapter);
    rootSpinner.setSelection(BasicNote.valueOf("C").ordinal());
    rootSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            updateForm();
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });

    sharpFlatSpinner = (Spinner) view.findViewById(R.id.sharpFlatSpinner);
    List<String> sfList = new ArrayList<>();
    for (int i = 0; i < 3; i++) { // only use the first 3 or you'll get DOUBLESHARP
        sfList.add(SharpFlat.values()[i].getSuffix());
    }
    MyArrayAdapter sfAdapter = new MyArrayAdapter(this.getContext(), R.layout.spinner_item, sfList);
    sfAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    sharpFlatSpinner.setAdapter(sfAdapter);
    sharpFlatSpinner.setSelection(SharpFlat.valueOf("NATURAL").ordinal());
    sharpFlatSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            updateForm();
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });

    triadSpinner = (Spinner) view.findViewById(R.id.triadSpinner);
    List<String> triadList = new ArrayList<>();
    for (Triad t : Triad.values()) {
        triadList.add(t.getName());
    }
    for (Seventh s : Seventh.values()) {
        triadList.add(s.getName());
    }
    for (Ninth n : Ninth.values()) {
        triadList.add(n.getName());
    }
    ArrayAdapter triadAdapter = new ArrayAdapter<>(this.getContext(), R.layout.spinner_item, triadList);
    triadAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    triadSpinner.setAdapter(triadAdapter);
    triadSpinner.setSelection(Triad.valueOf("MAJOR").ordinal());
    triadSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            updateForm();
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });

    chordNameText = (TextView) view.findViewById(R.id.chordNameText);
    notesText = (TextView) view.findViewById(R.id.notesText);

    add2Button = (CheckBox) view.findViewById(R.id.add2Button);
    add2Button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            updateForm();
        }
    });

    add4Button = (CheckBox) view.findViewById(R.id.add4Button);
    add4Button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            updateForm();
        }
    });

    sus4Button = (CheckBox) view.findViewById(R.id.sus4Button);
    sus4Button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            updateForm();
        }
    });

    add6Button = (CheckBox) view.findViewById(R.id.add6Button);
    add6Button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            updateForm();
        }
    });

    Button playButton = (Button) view.findViewById(R.id.playButton);
    playButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            player.play2(chord.getChordMask(), root.getNumber());
        }
    });

    Button setChordButton = (Button) view.findViewById(R.id.setChordButton);
    setChordButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            chordChangeListener.onChordChange(chord.getPitchMask(getRootNote()), getRootNote(), getChordArray(),
                    getChordAddArray());
        }
    });

    restoreInstanceState(savedInstanceState);

    return view;
}

From source file:com.gsma.rcs.provisioning.local.Provisioning.java

private void loadXmlFile() {
    final boolean logActivated = sLogger.isActivated();
    if (logActivated) {
        sLogger.debug("load XML provisioning File");
    }//  w  w w. j  a  v a2 s  .  c  o  m
    try {
        String[] xmlFiles = getProvisioningFiles();
        View view = View.inflate(mActivity, R.layout.rcs_provisioning_generate_profile, null);
        final EditText textEdit = (EditText) view.findViewById(R.id.msisdn);
        ContactId me = mRcsSettings.getUserProfileImsUserName();
        textEdit.setText(me == null ? "" : me.toString());
        final Spinner spinner = (Spinner) view.findViewById(R.id.XmlProvisioningFile);
        ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, xmlFiles);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(adapter);

        AlertDialog.Builder builder = new AlertDialog.Builder(this).setTitle(R.string.label_generate_profile)
                .setView(view).setNegativeButton(R.string.label_cancel, null)
                .setPositiveButton(R.string.label_ok, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        ContactUtil.PhoneNumber number = ContactUtil
                                .getValidPhoneNumberFromAndroid(textEdit.getText().toString());
                        if (number == null) {
                            Toast.makeText(mActivity, getString(R.string.label_load_failed), Toast.LENGTH_LONG)
                                    .show();
                            return;
                        }
                        ContactId contact = ContactUtil.createContactIdFromValidatedData(number);
                        String selectedProvisioningFile = (String) spinner.getSelectedItem();
                        if (selectedProvisioningFile == null
                                || selectedProvisioningFile.equals(getString(R.string.label_no_xml_file))) {
                            Toast.makeText(mActivity, getString(R.string.label_load_failed), Toast.LENGTH_LONG)
                                    .show();
                            return;
                        }
                        loadProfile(contact,
                                Uri.fromFile(new File(PROVISIONING_FOLDER_PATH, selectedProvisioningFile)));
                    }
                });
        AlertDialog dialog = builder.create();
        dialog.setCanceledOnTouchOutside(false);
        dialog.show();

    } catch (SecurityException e) {
        if (logActivated) {
            sLogger.warn("Failed to load provisioning file!", e);
        }
    }
}

From source file:edu.umich.flowfence.testapp.TestActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test);
    kvsValueField = (EditText) findViewById(R.id.kvs_value);
    shouldTaintBox = (CheckBox) findViewById(R.id.is_tainted);
    rootLayout = (RelativeLayout) findViewById(R.id.root_layout);
    sandboxCount = (Spinner) findViewById(R.id.sandbox_count);
    sandboxCountType = (Spinner) findViewById(R.id.sandbox_count_type);
    perfPassCount = (EditText) findViewById(R.id.perf_pass_count);
    taintPerfBox = (CheckBox) findViewById(R.id.perf_taint);

    // Set up adapter for sandbox count spinner
    CharSequence[] countList = new CharSequence[FlowfenceConstants.NUM_SANDBOXES + 1];
    for (int i = 0; i <= FlowfenceConstants.NUM_SANDBOXES; i++) {
        countList[i] = getResources().getQuantityString(R.plurals.sandbox_plurals, i, i);
    }// w  w  w .j a v a2  s  .c o m
    ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item,
            countList);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    sandboxCount.setAdapter(adapter);
    sandboxCount.setSelection(FlowfenceConstants.NUM_SANDBOXES);

    adapter = ArrayAdapter.createFromResource(this, R.array.sandbox_count_labels,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    sandboxCountType.setAdapter(adapter);

    setButtonsEnabled(false);
    connectToFlowfence(null);
}

From source file:edu.umich.oasis.testapp.TestActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test);
    kvsValueField = (EditText) findViewById(R.id.kvs_value);
    shouldTaintBox = (CheckBox) findViewById(R.id.is_tainted);
    rootLayout = (RelativeLayout) findViewById(R.id.root_layout);
    sandboxCount = (Spinner) findViewById(R.id.sandbox_count);
    sandboxCountType = (Spinner) findViewById(R.id.sandbox_count_type);
    perfPassCount = (EditText) findViewById(R.id.perf_pass_count);
    taintPerfBox = (CheckBox) findViewById(R.id.perf_taint);

    // Set up adapter for sandbox count spinner
    CharSequence[] countList = new CharSequence[OASISConstants.NUM_SANDBOXES + 1];
    for (int i = 0; i <= OASISConstants.NUM_SANDBOXES; i++) {
        countList[i] = getResources().getQuantityString(R.plurals.sandbox_plurals, i, i);
    }// w w  w  .jav a  2s  .c  o m
    ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item,
            countList);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    sandboxCount.setAdapter(adapter);
    sandboxCount.setSelection(OASISConstants.NUM_SANDBOXES);

    adapter = ArrayAdapter.createFromResource(this, R.array.sandbox_count_labels,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    sandboxCountType.setAdapter(adapter);

    setButtonsEnabled(false);
    connectToOASIS(null);
}

From source file:com.example.deii.trustone.SignUpActivity.java

private void InitViews() {

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    //toolbar.setTitle("Sign Up");
    setSupportActionBar(toolbar);/*from  w  w  w.j av a 2 s. c  om*/

    progressDialog = new CustomProgressDialog(this, R.drawable.syc);
    spinState = (Spinner) findViewById(R.id.spinState);

    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.state_array,
            R.layout.text_view);
    adapter.setDropDownViewResource(R.layout.text_view);
    spinState.setAdapter(adapter);
    spinState.setOnItemSelectedListener(this);

    imgProfile = (RoundedImageView) findViewById(R.id.imgProfile);
    imgProfile.setOnClickListener(this);

    txtConnect = (TextView) findViewById(R.id.txtConnect);
    txtConnect.setOnClickListener(this);

    tilName = (TextInputLayout) findViewById(R.id.tilName);
    edtName = (EditText) findViewById(R.id.edtName);
    edtName.addTextChangedListener(new MyTextWatcher(edtName));

    tilEmail = (TextInputLayout) findViewById(R.id.tilEmail);
    edtEmail = (EditText) findViewById(R.id.edtEmail);
    edtEmail.addTextChangedListener(new MyTextWatcher(edtEmail));

    tilPhone = (TextInputLayout) findViewById(R.id.tilPhone);
    edtPhone = (EditText) findViewById(R.id.edtPhone);
    edtPhone.addTextChangedListener(new MyTextWatcher(edtPhone));

    tilCity = (TextInputLayout) findViewById(R.id.tilCity);
    edtCity = (EditText) findViewById(R.id.edtCity);
    edtCity.addTextChangedListener(new MyTextWatcher(edtCity));

    tilLicense = (TextInputLayout) findViewById(R.id.tilLicense);
    edtLicense = (EditText) findViewById(R.id.edtLicense);

    tilPassword = (TextInputLayout) findViewById(R.id.tilPassword);
    edtPassword = (EditText) findViewById(R.id.edtPassword);
    edtPassword.addTextChangedListener(new MyTextWatcher(edtPassword));

    tilConfPassword = (TextInputLayout) findViewById(R.id.tilConfPassword);
    edtConfPassword = (EditText) findViewById(R.id.edtPassword);
    edtConfPassword.addTextChangedListener(new MyTextWatcher(edtConfPassword));

    functions = new CommonFunctions(this);
}

From source file:com.tsroad.map.poisearch.PoiAroundSearchActivity.java

/**
 * //  w  w w  .jav  a 2s . c o m
 */
private void setUpMap() {
    selectDeep = (Spinner) findViewById(R.id.spinnerdeep);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
            itemDeep);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    selectDeep.setAdapter(adapter);
    selectDeep.setOnItemSelectedListener(this);// spinner?
    aMap.setOnMarkerClickListener(this);// marker?
    aMap.setInfoWindowAdapter(this);// infowindow?

}

From source file:com.tsroad.map.poisearch.PoiAroundSearchActivity.java

/**
 * /*from w ww. j a v  a2  s  . c o m*/
 */
private void setSelectType() {
    selectType = (Spinner) findViewById(R.id.searchType);// ?
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
            itemTypes);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    selectType.setAdapter(adapter);
    selectType.setOnItemSelectedListener(this);// spinner?
    aMap.setOnMarkerClickListener(this);// marker?
    aMap.setInfoWindowAdapter(this);// infowindow?
}

From source file:com.flowzr.activity.RecurActivity.java

private void addSpinnerItems(Spinner spinner, LocalizableEnum[] a) {
    int length = a.length;
    SpinnerItem[] items = new SpinnerItem[length];
    for (int i = 0; i < length; i++) {
        LocalizableEnum x = a[i];//from w  w  w  .  ja  v a  2s .c  o  m
        String title = getString(x.getTitleId());
        String value = x.name();
        items[i] = new SpinnerItem(title, value);
    }
    ArrayAdapter<SpinnerItem> adapter = new ArrayAdapter<SpinnerItem>(this,
            android.R.layout.simple_spinner_item, items);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
}

From source file:com.mifos.mifosxdroid.online.SavingsAccountFragment.java

private void inflateInterestPostingPeriodType() {

    final ArrayList<String> InterestPostingPeriodTypeNames = filterListObject(
            savingproductstemplate.getInterestPostingPeriodTypeOptions());

    final ArrayAdapter<String> interestPostingPeriodTypeAdapter = new ArrayAdapter<>(getActivity(),
            layout.simple_spinner_item, InterestPostingPeriodTypeNames);

    interestPostingPeriodTypeAdapter.setDropDownViewResource(layout.simple_spinner_dropdown_item);
    sp_interest_p_period.setAdapter(interestPostingPeriodTypeAdapter);
    sp_interest_p_period.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override//from   w  w w.  ja va 2 s.  co  m
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            interestPostingPeriodTypeId = savingproductstemplate.getInterestPostingPeriodTypeOptions().get(i)
                    .getId();
            Log.d("interestPosting " + InterestPostingPeriodTypeNames.get(i),
                    String.valueOf(interestPostingPeriodTypeId));
            if (interestPostingPeriodTypeId != -1) {

            } else {

                Toast.makeText(getActivity(), getString(R.string.interestPostingPeriodTypeId),
                        Toast.LENGTH_SHORT).show();

            }

        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    });

}

From source file:com.mifos.mifosxdroid.online.SavingsAccountFragment.java

private void interestCompoundingPeriodType() {

    final ArrayList<String> InterestCompoundingPeriodType = filterListObject(
            savingproductstemplate.getInterestCompoundingPeriodTypeOptions());

    final ArrayAdapter<String> interestCompoundingPeriodTypeAdapter = new ArrayAdapter<>(getActivity(),
            layout.simple_spinner_item, InterestCompoundingPeriodType);
    interestCompoundingPeriodTypeAdapter.setDropDownViewResource(layout.simple_spinner_dropdown_item);
    sp_interest_comp.setAdapter(interestCompoundingPeriodTypeAdapter);
    sp_interest_comp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override// w ww .j  a v  a 2  s  .  com
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            interestCompoundingPeriodTypeId = savingproductstemplate.getInterestCompoundingPeriodTypeOptions()
                    .get(i).getId();
            Log.d("clientTypeId " + InterestCompoundingPeriodType.get(i),
                    String.valueOf(interestCompoundingPeriodTypeId));
            if (interestCompoundingPeriodTypeId != -1) {

            } else {

                Toast.makeText(getActivity(), getString(R.string.error_select_intrested_cmp),
                        Toast.LENGTH_SHORT).show();

            }

        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    });

}