Example usage for android.widget Spinner setAdapter

List of usage examples for android.widget Spinner setAdapter

Introduction

In this page you can find the example usage for android.widget Spinner setAdapter.

Prototype

@Override
public void setAdapter(SpinnerAdapter adapter) 

Source Link

Document

Sets the SpinnerAdapter used to provide the data which backs this Spinner.

Usage

From source file:at.bitfire.davdroid.ui.CreateAddressBookActivity.java

@Override
public void onLoadFinished(Loader<AccountInfo> loader, AccountInfo info) {
    if (info != null) {
        Spinner spinner = (Spinner) findViewById(R.id.home_sets);
        spinner.setAdapter(
                new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, info.homeSets));
    }//from   w  w w  . ja  v a  2  s .c  om
}

From source file:org.jboss.aerogear.devnexus2015.ui.fragment.AboutFragment.java

private void loadSpinnerNav(Spinner spinner) {
    spinner.setAdapter(new AboutNavigationSpinnerAdapter(getActivity()));
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override//from   ww w. ja v a2 s  . c o  m
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
            case 0:
                loadSponsors();
                break;
            case 1:
                loadOSS();
                break;
            }
        }

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

From source file:com.NotifyMe.auth.SignInActivity.java

private Spinner initializeSpinner(int id, String[] values) {
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(SignInActivity.this,
            android.R.layout.simple_spinner_item, values);
    Spinner spinner = (Spinner) findViewById(id);
    spinner.setAdapter(adapter);
    return spinner;
}

From source file:ru.glesik.wifireminders.AddReminderActivity.java

protected void onResume() {
    super.onResume();
    // Creating adapter to populate spinnerSSID items.
    adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    Spinner Items = (Spinner) findViewById(R.id.spinnerSSID);
    Items.setAdapter(adapter);
    WifiManager mainWifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    // Start scanning for visible networks.
    if (mainWifi.isWifiEnabled()) {
        mainWifi.startScan();/*from  w w  w  . j a  v  a  2s  .c o m*/
        // Getting list of stored networks.
        List<WifiConfiguration> wifiList = mainWifi.getConfiguredNetworks();
        for (WifiConfiguration result : wifiList) {
            // Removing quotes.
            adapter.add(result.SSID.toString().replaceAll("^\"|\"$", ""));
        }
        adapter.notifyDataSetChanged();
    } else {
        new AlertDialog.Builder(this).setTitle(R.string.error_wifi_off_title)
                .setMessage(R.string.error_wifi_off_text)
                .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        startActivity(new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK));
                        finish();
                    }
                }).setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        finish();
                    }
                }).setIcon(android.R.drawable.ic_dialog_alert).show();
    }
}

From source file:org.deviceconnect.android.uiapp.fragment.profile.ExtraProfileFragment.java

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

    View view = inflater.inflate(R.layout.fragment_extra_service, container, false);
    view.setBackgroundColor(getResources().getColor(android.R.color.background_light));

    final String[] methods = { "GET", "POST", "PUT", "DELETE" };
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),
            android.R.layout.simple_spinner_item);
    for (int i = 0; i < methods.length; i++) {
        adapter.add(methods[i]);//from   ww  w.java2  s  . c  o  m
    }
    Spinner spinner = (Spinner) view.findViewById(R.id.spinner);
    spinner.setAdapter(adapter);

    Button sendButton = (Button) view.findViewById(R.id.fragment_extra_send);
    sendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View view) {
            onClickSend(view);
        }
    });

    return view;
}

From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceTimeProfile.java

final static private void setSpinnerHour(final GlobalParameters mGlblParms, Dialog dialog, Spinner spinner,
        CustomSpinnerAdapter adapter, String selected) {
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setPrompt(mGlblParms.context.getString(R.string.msgs_edit_profile_time_select_hour));
    spinner.setAdapter(adapter);
    adapter.clear();/*from   w w  w .j  a v  a2 s  . co m*/

    for (int i = 0; i <= 23; i++)
        if (i > 9)
            adapter.add("" + i);
        else
            adapter.add("0" + i);
    String hh = selected.substring(0, selected.indexOf(":"));
    if (!hh.equals("**")) {
        int hour = Integer.parseInt(hh);
        spinner.setSelection(hour);
    } else
        spinner.setSelection(0);
}

From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceTimeProfile.java

final static private void setSpinnerMin(final GlobalParameters mGlblParms, Dialog dialog, Spinner spinner,
        CustomSpinnerAdapter adapter, String selected) {
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setPrompt(mGlblParms.context.getString(R.string.msgs_edit_profile_time_select_min));
    spinner.setAdapter(adapter);
    adapter.clear();/*from   w  ww .j  a  va 2  s.  c o  m*/

    for (int i = 0; i <= 59; i++)
        if (i > 9)
            adapter.add("" + i);
        else
            adapter.add("0" + i);
    String hh = selected.substring(0, selected.indexOf(":"));
    String mm = selected.replace(hh + ":", "");
    if (!mm.equals("**")) {
        int min = Integer.parseInt(mm);
        spinner.setSelection(min);
    } else
        spinner.setSelection(0);
}

From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceTimeProfile.java

final static private void setSpinnerDay(final GlobalParameters mGlblParms, Dialog dialog, Spinner spinner,
        CustomSpinnerAdapter adapter, String selected) {
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setPrompt(mGlblParms.context.getString(R.string.msgs_edit_profile_time_select_day));
    spinner.setAdapter(adapter);
    adapter.clear();//from www.j av a 2  s .  c o  m

    for (int i = 1; i <= 31; i++)
        if (i > 9)
            adapter.add("" + i);
        else
            adapter.add("0" + i);
    String yyyy = selected.substring(0, selected.indexOf("/"));
    String mm = selected.replace(yyyy + "/", "").substring(0, 2);
    String dd = selected.replace(yyyy + "/" + mm + "/", "");
    if (!dd.equals("**")) {
        int day = Integer.parseInt(dd);
        spinner.setSelection(day - 1);
    } else
        spinner.setSelection(0);
}

From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceTimeProfile.java

final static private void setSpinnerMonth(final GlobalParameters mGlblParms, Dialog dialog, Spinner spinner,
        CustomSpinnerAdapter adapter, String selected) {
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setPrompt(mGlblParms.context.getString(R.string.msgs_edit_profile_time_select_month));
    spinner.setAdapter(adapter);
    adapter.clear();//  w w  w .ja  v  a2s  .  c om

    for (int i = 1; i <= 12; i++)
        if (i > 9)
            adapter.add("" + i);
        else
            adapter.add("0" + i);
    String yyyy = selected.substring(0, selected.indexOf("/"));
    String mm = selected.replace(yyyy + "/", "").substring(0, 2);
    if (!mm.equals("**")) {
        int month = Integer.parseInt(mm);
        spinner.setSelection(month - 1);
    } else
        spinner.setSelection(0);
}

From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceTimeProfile.java

final static private void setSpinnerDateTimeType(final GlobalParameters mGlblParms, Dialog dialog,
        Spinner spinner, AdapterDateTimeTypeSpinner adapter, String selected) {
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setPrompt(mGlblParms.context.getString(R.string.msgs_edit_profile_time_select_date_time_type));
    spinner.setAdapter(adapter);
    adapter.clear();//from  w w w. j  av a2 s  .co m

    adapter.add(PROFILE_DATE_TIME_TYPE_ONE_SHOT);
    adapter.add(PROFILE_DATE_TIME_TYPE_EVERY_YEAR);
    adapter.add(PROFILE_DATE_TIME_TYPE_EVERY_MONTH);
    adapter.add(PROFILE_DATE_TIME_TYPE_EVERY_DAY);
    adapter.add(PROFILE_DATE_TIME_TYPE_EVERY_HOUR);
    adapter.add(PROFILE_DATE_TIME_TYPE_DAY_OF_THE_WEEK);
    adapter.add(PROFILE_DATE_TIME_TYPE_INTERVAL);
    for (int i = 0; i < adapter.getCount(); i++)
        if (adapter.getItem(i).equals(selected))
            spinner.setSelection(i);

}