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.pawnua.android.app.licenseplates.MainActivity.java

private void setUpSpinner() {
    spinner = (Spinner) findViewById(R.id.spinner_nav);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override/*from   w w  w .j a  va2 s.c  o m*/
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            spinnerPosition = position;
        }

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

        }
    });

    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(toolbar.getContext(),
            R.array.submenu_array, R.layout.spinner_dropdown_item);
    adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);

    spinner.setAdapter(adapter);
}

From source file:com.cyrilmottier.android.polaris2demo.LayersDemoActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layers_demo);

    Spinner spinner = (Spinner) findViewById(R.id.layers_spinner);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.layers_array,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);/*from www . java  2  s .c  om*/
    spinner.setOnItemSelectedListener(this);

    mTrafficCheckbox = (CheckBox) findViewById(R.id.traffic);
    mMyLocationCheckbox = (CheckBox) findViewById(R.id.my_location);

    setUpMapIfNeeded();
}

From source file:com.simplechatclient.android.LoginFragment.java

public void myStart() {

    Config current_config = new Config(context);
    List<DatabaseProfile> profiles = current_config.getProfiles();

    profiles_list = new ArrayList<String>();
    for (DatabaseProfile profile : profiles) {
        profiles_list.add(profile.getNick());
    }/*from  w  w  w.  ja v a 2  s .  c o  m*/

    Button login = (Button) view.findViewById(R.id.button_login);
    Spinner spinner = (Spinner) view.findViewById(R.id.spinnerNick);

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_item,
            profiles_list);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);

    String nick = Settings.getInstance().get("nick");
    int default_position = profiles_list.indexOf(nick);
    if (default_position != -1)
        spinner.setSelection(default_position);

    spinner.setOnItemSelectedListener(spinnerListener);
    login.setOnClickListener(this);
}

From source file:com.currency.org.CurrencyConverterActivity.java

/** Called when the activity is first created. */
@Override/* w ww .ja va 2s  .c o m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    Spinner s1 = (Spinner) findViewById(R.id.spinner1);
    Spinner s2 = (Spinner) findViewById(R.id.spinner2);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.name,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.select_dialog_singlechoice);
    val = getResources().getStringArray(R.array.value);
    s1.setAdapter(adapter);
    s2.setAdapter(adapter);
    s1.setOnItemSelectedListener(new spinOne(1));
    s2.setOnItemSelectedListener(new spinOne(2));
    Button b = (Button) findViewById(R.id.button1);
    b.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            TextView t = (TextView) findViewById(R.id.textView4);
            if (from == to) {
                Toast.makeText(getApplicationContext(), "Invalid", 4000).show();
            } else {
                try {
                    s = getJson(
                            "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%20in%20(%22"
                                    + val[from] + val[to]
                                    + "%22)&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=");
                    JSONObject jObj;
                    jObj = new JSONObject(s);
                    String exResult = jObj.getJSONObject("query").getJSONObject("results").getJSONObject("rate")
                            .getString("Rate");
                    t.setText(exResult);
                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (ClientProtocolException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    });
}

From source file:am.roadpolice.roadpolice.dialogs.DialogSettings.java

private void initUpdateIntervals(final View view) {
    Spinner spinner = (Spinner) view.findViewById(R.id.spinnerUpdateInterval);
    ArrayAdapter adapter = ArrayAdapter.createFromResource(getActivity(), R.array.array_update_interval,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);/*from  w w w.  jav  a2 s  . c  o m*/

    spinner.setSelection(getUpdateInterval(getActivity()));

    // Handle on click selected item listener.
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            mSelectedStateOfUpdateInterval = position;
        }

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

From source file:com.anton.gavel.PersonalInfoDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    LayoutInflater inflater = getActivity().getLayoutInflater();
    dialogView = inflater.inflate(R.layout.dialog_personal_info, null);

    Spinner spinner = (Spinner) dialogView.findViewById(R.id.personal_cities_spinner);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.cities,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);//  ww  w  .  ja va2 s  .  c  om

    builder.setView(dialogView).setTitle("Personal Information")
            .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    mListener.onDialogPositiveClick(PersonalInfoDialogFragment.this);
                }
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    PersonalInfoDialogFragment.this.getDialog().cancel();
                }
            });
    populatePersonalInfo();
    return builder.create();
}

From source file:de.nico.ha_manager.activities.AddHomework.java

private void setSpinner() {
    // Set spinner with subjects
    Spinner subSpin = (Spinner) findViewById(R.id.spinner_subject);
    ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, subjects);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    subSpin.setAdapter(adapter);/*from   www.  j a  v  a2 s  .c  om*/
}

From source file:com.fjn.magazinereturncandidate.fragments.InputJanCodeFragment.java

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

    //Init custom product detail layout
    View rootView = inflater.inflate(R.layout.fragment_input_jan, container, false);
    if (getDialog().getWindow() != null) {
        getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
        getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    }/*from  w ww  .  j  a v a2 s .c om*/

    //Get flag setting OCR
    if (getArguments() != null) {
        flagSwitchOCR = getArguments().getString(Constants.FLAG_SWITCH_OCR);
    }

    //Get Id textView Product detail
    txv_jan_cd = (TextView) rootView.findViewById(R.id.txv_jan_cd_input);
    txv_inventory_number = (TextView) rootView.findViewById(R.id.txv_inventory_number_input);
    Button btn_submit_edit = (Button) rootView.findViewById(R.id.btn_submit_edit_input);
    // Set adapter for combo box with array
    ArrayAdapter<String> adapter1 = new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1, arr);
    // Set item selected
    adapter1.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
    // Set button click
    btn_submit_edit.setOnClickListener(this);

    //Set default end text
    txv_jan_cd.setText("");
    txv_jan_cd.append(Constants.PREFIX_JAN_CODE_MAGAZINE); //focus end text
    //Show keyboard
    txv_jan_cd.requestFocus();
    getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);

    checkDataCommon = new CheckDataCommon();
    registerLicenseCommon = new RegisterLicenseCommon();
    formatCommon = new FormatCommon();
    hsmDecoder = HSMDecoder.getInstance(getActivity());
    return rootView;
}

From source file:com.example.multi_ndef.frag_bt.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.frag_bt, container, false);

    btSpinner = (Spinner) v.findViewById(R.id.spinnerbt);
    btSpinner.setOnItemSelectedListener(this);
    ma = (CNFCInterface) getActivity().getApplication();
    try {//from   w w  w. j a  v  a  2  s. c  o  m
        BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

        Set<BluetoothDevice> pairedDevices = bluetoothAdapter.getBondedDevices();

        if (pairedDevices.size() > 0) {
            for (BluetoothDevice device : pairedDevices) {
                String deviceBTName = device.getName();
                String address = device.getAddress();
                //String deviceBTMajorClass = getBTMajorDeviceClass(device.getBluetoothClass().getMajorDeviceClass());
                SpinnerArrayBT_Device_name.add(deviceBTName);
                SpinnerArrayBT_devices_mac.add(address);
            }
        }
    } catch (Exception e)
    //SpinnerArrayBT.a
    {

        Toast toast = Toast.makeText(getActivity().getApplicationContext(), "Bluetooth Code Error",
                Toast.LENGTH_SHORT);
        toast.show();

        int a1 = 10;
    }

    ArrayAdapter<String> btArrayAdapter = new ArrayAdapter<String>(this.getActivity(),
            android.R.layout.simple_spinner_item, SpinnerArrayBT_Device_name);
    btArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    btSpinner.setAdapter(btArrayAdapter);

    return v;
}

From source file:com.tomohamat.apicem.SwitchFragment.java

public void setNetworkDevices(ArrayList<NetworkDevice> devices) {
    networkDevices = new ArrayList<NetworkDevice>();
    switches = new ArrayList<NetworkDevice>();
    List<String> spinnerArray = new ArrayList<String>();

    if (null != devices) {
        for (NetworkDevice device : devices) {
            networkDevices.add(device);/*from w  ww  .j av  a 2  s .  c  o m*/
            if (device.isSwitch()) {
                switches.add(device);
                spinnerArray.add(device.getHostname());
            }
        }
    }
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this.getContext(),
            android.R.layout.simple_spinner_item, spinnerArray);

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

    if (0 < switches.size()) {
        enableButtons();
    } else {
        disableButtons();
    }
}