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:de.uni_koblenz_landau.apow.SettingsFragment.java

/**
 * Called by settings task, when loading is finished.
 *//* www . j  a v a2  s . c o m*/
@Override
public void onSettingsFetched(ListViewItem settings, List<ListViewItem> locations) {
    mSettingsTask = null;

    // If result is not empty, update UI, else show error message.
    if (settings != null && locations != null) {
        mSettings = settings;
        mUsernameView.setText(mSettings.getField1());
        mPasswordView.setText(mSettings.getField2());
        mLocations = locations;
        ArrayAdapter<ListViewItem> adapter = new ArrayAdapter<>(getActivity(),
                android.R.layout.simple_spinner_item, locations);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        mLocationsView.setAdapter(adapter);
        int position = -1;
        for (int i = 0; i < adapter.getCount(); i++) {
            if (adapter.getItem(i).getId() == settings.getId()) {
                position = i;
                break;
            }
        }
        mLocationsView.setSelection(position);
    } else {
        Toast.makeText(getActivity(), R.string.error_database, Toast.LENGTH_SHORT).show();
    }
}

From source file:com.tmall.ultraviewpager.sample.PagerActivity.java

private void initUI() {
    indicatorStyle = (Spinner) findViewById(R.id.indicator);
    indicatorGravityHor = (Spinner) findViewById(R.id.indicator_gravity_hor);
    indicatorGravityVer = (Spinner) findViewById(R.id.indicator_gravity_ver);

    ArrayAdapter<CharSequence> indicatorAdapter = ArrayAdapter.createFromResource(this, R.array.indicator_style,
            android.R.layout.simple_spinner_item);
    indicatorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    indicatorStyle.setAdapter(indicatorAdapter);

    ArrayAdapter<CharSequence> indicatorGraHorAdapter = ArrayAdapter.createFromResource(this,
            R.array.indicator_gravity_hor, android.R.layout.simple_spinner_item);
    indicatorGraHorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    indicatorGravityHor.setAdapter(indicatorGraHorAdapter);

    ArrayAdapter<CharSequence> indicatorGraVerAdapter = ArrayAdapter.createFromResource(this,
            R.array.indicator_gravity_ver, android.R.layout.simple_spinner_item);
    indicatorGraVerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    indicatorGravityVer.setAdapter(indicatorGraVerAdapter);

    indicatorStyle.setOnItemSelectedListener(this);
    indicatorGravityHor.setOnItemSelectedListener(this);
    indicatorGravityVer.setOnItemSelectedListener(this);

    loopCheckBox = (CheckBox) findViewById(R.id.loop);
    loopCheckBox.setOnCheckedChangeListener(this);

    autoScrollCheckBox = (CheckBox) findViewById(R.id.autoscroll);
    autoScrollCheckBox.setOnCheckedChangeListener(this);

    indicatorBuildBtn = (Button) findViewById(R.id.indicator_build);
    indicatorBuildBtn.setOnClickListener(this);
}

From source file:com.uoit.freeroomfinder.FreeRoom.java

@Override
public void onResume() {
    super.onResume();

    // Set up the time spinner to include the current time.
    int timeValues = R.array.time_values;

    // Set the time to display the correct time format.
    if (!sharedPrefs.getBoolean("army_clock", true)) {
        timeValues = R.array.army_time_values;
    }// w ww .  j  a  v  a  2 s . c o  m

    ArrayList<String> spinnerArray = new ArrayList<String>(
            Arrays.asList(this.getResources().getStringArray(timeValues)));
    spinnerArray.add(0, "Now");

    ArrayAdapter<String> sa = new ArrayAdapter<String>(this.getActivity(), android.R.layout.simple_spinner_item,
            spinnerArray);
    sa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    timeSpinner.setAdapter(sa);

}

From source file:edu.cmu.cylab.starslinger.view.FindContactActivity.java

public void generateView() {
    setContentView(R.layout.contact_adder);

    final ActionBar bar = getSupportActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    bar.setTitle(R.string.app_name);//from  w  w w .j  a va 2  s  . c o  m
    bar.setSubtitle(R.string.title_find);

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    // Obtain handles to UI objects
    mEditTextName = (EditText) findViewById(R.id.contactNameEditText);
    mButtonDone = (Button) findViewById(R.id.contactDoneButton);
    mEditTextPassNext = (EditText) findViewById(R.id.EditTextPassphrase);
    mEditTextPassDone = (EditText) findViewById(R.id.EditTextPassphraseAgain);
    mTextViewLicensePrivacy = (TextView) findViewById(R.id.textViewLicensePrivacy);
    mSpinnerLanguage = (Spinner) findViewById(R.id.spinnerLanguage);

    final ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(this,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    final ArrayList<String> codes = SafeSlinger.getApplication().getListLanguages(true);
    mSpinnerLanguage.setPrompt(getText(R.string.title_language));
    mSpinnerLanguage.setAdapter(adapter);
    ArrayList<String> all = SafeSlinger.getApplication().getListLanguages(false);
    for (String l : all) {
        adapter.add(l);
    }
    mSpinnerLanguage.setSelection(codes.indexOf(SafeSlingerPrefs.getLanguage()));

    // read defaults and set them
    mSelectedName = SafeSlingerPrefs.getContactName();

    // see if name is there...
    if (mSelectedName != null) {
        mEditTextName.setText(mSelectedName);
    }

    mEditTextPassNext.setVisibility(View.VISIBLE);
    mEditTextPassNext.setHint(R.string.label_PassHintCreate);
    mEditTextPassDone.setHint(R.string.label_PassHintRepeat);

    // enable hyperlinks
    mTextViewLicensePrivacy.setText(Html.fromHtml("<a href=\"" + SafeSlingerConfig.EULA_URL + "\">"
            + getText(R.string.menu_License) + "</a> / <a href=\"" + SafeSlingerConfig.PRIVACY_URL + "\">"
            + getText(R.string.menu_PrivacyPolicy) + "</a>"));
    mTextViewLicensePrivacy.setMovementMethod(LinkMovementMethod.getInstance());

    mSpinnerLanguage.setOnItemSelectedListener(new OnItemSelectedListener() {

        @TargetApi(Build.VERSION_CODES.HONEYCOMB)
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long i) {

            if (!codes.get(position).equals(SafeSlingerPrefs.getLanguage())) {
                SafeSlingerPrefs.setLanguage(codes.get(position));
                SafeSlinger.getApplication().updateLanguage(codes.get(position));
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                    recreate();
                } else {
                    generateView();
                }
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // We don't need to worry about nothing being selected
        }
    });

    mEditTextName.setOnFocusChangeListener(new OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            mSelectedName = mEditTextName.getText().toString();
        }
    });

    mButtonDone.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onDoneButtonClicked();
        }
    });

    mEditTextPassDone.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                doValidatePassphrase();
                return true;
            }
            return false;
        }
    });
}

From source file:com.andryr.musicplayer.activities.EqualizerActivity.java

private void initPresets() {

    ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item,
            AudioEffects.getEqualizerPresets(this));

    mSpinner = (Spinner) findViewById(R.id.presets_spinner);

    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    mSpinner.setAdapter(adapter);/* w w w  .  j a  v a2  s .co m*/

    mSpinner.setSelection(AudioEffects.getCurrentPreset());

    mSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (position >= 1) {
                AudioEffects.usePreset((short) (position - 1));
            }
            updateSeekBars();

        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // TODO Auto-generated method stub

        }
    });
}

From source file:com.armtimes.dialogs.DialogSettings.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    View settingsView = getActivity().getLayoutInflater().inflate(R.layout.dialog_settings, null);

    // Initialize and set Storage Spinner adapter.
    Spinner storageSpinner = (Spinner) settingsView.findViewById(R.id.spinnerImageStorage);
    ArrayAdapter storageAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.image_storage_array,
            android.R.layout.simple_spinner_item);
    storageAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    storageSpinner.setAdapter(storageAdapter);

    storageSpinner.setSelection(getImageStorage(getActivity()));

    storageSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override//  www.  jav  a 2s  .  c  om
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            setImageStorage(position);
        }

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

    // Initialize and set Saved news number Spinner Adapter
    Spinner savedNewsSpinner = (Spinner) settingsView.findViewById(R.id.spinnerStoredArticlesCount);
    ArrayAdapter savedNewsAdapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.saved_articles_number_array, android.R.layout.simple_spinner_item);
    savedNewsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    savedNewsSpinner.setAdapter(savedNewsAdapter);

    int pos = savedNewsAdapter.getPosition(Integer.toString(getAllowedNewsCount(getActivity())));
    savedNewsSpinner.setSelection(pos);

    savedNewsSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            final String value = (String) parent.getItemAtPosition(position);
            setSavedNewsCount(value);
        }

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

    initImageQualityControllers(settingsView);
    initFontSizeStuff(settingsView);

    // Creates About Us Alert dialog which extends from DialogFragment.
    return new AlertDialog.Builder(getActivity()).setTitle(R.string.settings)
            .setNeutralButton(R.string.about_us_close, null).setView(settingsView).create();
}

From source file:de.uni_koblenz_landau.apow.SettingsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.settings_fragment, container, false);

    // Create UI references.
    mUsernameView = (EditText) view.findViewById(R.id.settings_username);
    mPasswordView = (EditText) view.findViewById(R.id.settings_password);
    mLocationsView = (Spinner) view.findViewById(R.id.settings_locations);
    mFormView = view.findViewById(R.id.settings_form);
    mStatusView = view.findViewById(R.id.settings_status);
    mStatusMessageView = (TextView) view.findViewById(R.id.settings_status_message);

    // Restore UI from saved instance or load data.
    if (savedInstanceState != null) {
        mSettings = savedInstanceState.getParcelable(ARG_SETTINGS);
        if (mSettings != null) {
            mLocations = savedInstanceState.getParcelableArrayList(ARG_LOCATIONS);
            ArrayAdapter<ListViewItem> adapter = new ArrayAdapter<>(getActivity(),
                    android.R.layout.simple_spinner_item, mLocations);
            adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            mLocationsView.setAdapter(adapter);
        }/*w  ww .  j a  v  a2  s . c  o  m*/
    } else {
        loadSettings();
    }

    return view;
}

From source file:com.google.firebase.samples.apps.mlkit.java.LivePreviewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "onCreate");

    setContentView(R.layout.activity_live_preview);

    preview = (CameraSourcePreview) findViewById(R.id.firePreview);
    if (preview == null) {
        Log.d(TAG, "Preview is null");
    }/*from   w  ww .j a  va  2s  .co  m*/
    graphicOverlay = (GraphicOverlay) findViewById(R.id.fireFaceOverlay);
    if (graphicOverlay == null) {
        Log.d(TAG, "graphicOverlay is null");
    }

    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    List<String> options = new ArrayList<>();
    options.add(FACE_CONTOUR);
    options.add(FACE_DETECTION);
    options.add(TEXT_DETECTION);
    options.add(BARCODE_DETECTION);
    options.add(IMAGE_LABEL_DETECTION);
    options.add(CLASSIFICATION_QUANT);
    options.add(CLASSIFICATION_FLOAT);
    // Creating adapter for spinner
    ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, R.layout.spinner_style, options);
    // Drop down layout style - list view with radio button
    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // attaching data adapter to spinner
    spinner.setAdapter(dataAdapter);
    spinner.setOnItemSelectedListener(this);

    ToggleButton facingSwitch = (ToggleButton) findViewById(R.id.facingSwitch);
    facingSwitch.setOnCheckedChangeListener(this);
    // Hide the toggle button if there is only 1 camera
    if (Camera.getNumberOfCameras() == 1) {
        facingSwitch.setVisibility(View.GONE);
    }

    if (allPermissionsGranted()) {
        createCameraSource(selectedModel);
    } else {
        getRuntimePermissions();
    }
}

From source file:com.jaspersoft.android.jaspermobile.activities.save.fragment.SaveItemFragment.java

@AfterViews
final void init() {
    // show spinner with available output formats
    ArrayAdapter<OutputFormat> arrayAdapter = new ArrayAdapter<OutputFormat>(getActivity(),
            android.R.layout.simple_spinner_item, OutputFormat.values());
    arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    formatSpinner.setAdapter(arrayAdapter);

    reportNameInput.setText(resource.getLabel());

    // hide save parts views if report have only 1 page
    if (pageCount > 1) {
        rangeControls.setVisibility(View.VISIBLE);

        mFromPage = 1;//ww  w  . j  a  v  a 2  s . c om
        mToPage = pageCount;

        fromPageControl.setText(String.valueOf(mFromPage));
        toPageControl.setText(String.valueOf(mToPage));
    }
}

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

public void inflatePaymentOptions() {
    App.apiManager.getSavingsAccountTemplate(savingsAccountType.getEndpoint(),
            Integer.parseInt(savingsAccountNumber.replaceAll("[^\\d-]", "")), transactionType,
            new Callback<SavingsAccountTransactionTemplate>() {
                @Override/*from   w ww . j  a v a 2  s  .co m*/
                public void success(SavingsAccountTransactionTemplate savingsAccountTransactionTemplate,
                        Response response) {
                    /* Activity is null - Fragment has been detached; no need to do anything. */
                    if (getActivity() == null)
                        return;

                    if (savingsAccountTransactionTemplate != null) {
                        List<String> listOfPaymentTypes = new ArrayList<>();
                        paymentTypeOptionList = savingsAccountTransactionTemplate.getPaymentTypeOptions();
                        // Sorting has to be done on the basis of
                        // PaymentTypeOption.position because it is specified
                        // by the users on Mifos X Platform.
                        Collections.sort(paymentTypeOptionList);
                        Iterator<PaymentTypeOption> paymentTypeOptionIterator = paymentTypeOptionList
                                .iterator();
                        while (paymentTypeOptionIterator.hasNext()) {
                            PaymentTypeOption paymentTypeOption = paymentTypeOptionIterator.next();
                            listOfPaymentTypes.add(paymentTypeOption.getName());
                            paymentTypeHashMap.put(paymentTypeOption.getName(), paymentTypeOption.getId());
                        }
                        ArrayAdapter<String> paymentTypeAdapter = new ArrayAdapter<>(getActivity(),
                                layout.simple_spinner_item, listOfPaymentTypes);

                        paymentTypeAdapter.setDropDownViewResource(layout.simple_spinner_dropdown_item);
                        sp_paymentType.setAdapter(paymentTypeAdapter);
                    }
                    showProgress(false);
                }

                @Override
                public void failure(RetrofitError retrofitError) {
                    showProgress(false);
                }
            });
}