Example usage for android.widget Spinner setPrompt

List of usage examples for android.widget Spinner setPrompt

Introduction

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

Prototype

public void setPrompt(CharSequence prompt) 

Source Link

Document

Sets the prompt to display when the dialog is shown.

Usage

From source file:com.hybris.mobile.app.commerce.helper.ProductHelper.java

/**
 * Fill Spinner list with arraylist of variantMatrixElement
 *
 * @param context//  w  w w .  ja va 2 s  .co  m
 * @param spinner
 * @param variants
 * @param position
 */
public static void populateSpinner(Context context, Spinner spinner, List<VariantOption> variants,
        int position) {
    if (spinner != null && variants != null && !variants.isEmpty()) {
        VariantAdapter mVariantAdapter = new VariantAdapter(context, R.layout.item_product_variant, variants);
        spinner.setAdapter(mVariantAdapter);
        spinner.setPrompt(context.getString(R.string.choose_variant,
                ((List<VariantOptionQualifier>) variants.get(0).getVariantOptionQualifiers()).get(0)
                        .getName()));
        spinner.setVisibility(View.VISIBLE);
        spinner.setSelection(position < variants.size() ? position : 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);/*ww w. j  a  va  2  s  . co m*/
    adapter.clear();

    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);

}

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);//from   w  ww  .j  a  v  a  2 s. c om
    adapter.clear();

    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 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);/*from   w w w  .java 2 s  . c  o  m*/
    adapter.clear();

    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 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);/*from  ww w.j  ava2  s . c  o  m*/
    adapter.clear();

    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);/*from   w ww. j  a  v  a2 s.  co m*/
    adapter.clear();

    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 setSpinnerYear(final GlobalParameters mGlblParms, Dialog dialog, Spinner spinner,
        CustomSpinnerAdapter adapter, String selected) {
    SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy/MM/dd", Locale.getDefault());
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setPrompt(mGlblParms.context.getString(R.string.msgs_edit_profile_time_select_year));
    spinner.setAdapter(adapter);//from   w  w w. j  a  v a 2s.co  m
    adapter.clear();

    String yyyy = selected.substring(0, selected.indexOf("/"));
    if (yyyy.equals("****")) {
        String tyy = sdfDate.format(System.currentTimeMillis());
        yyyy = tyy.substring(0, tyy.indexOf("/"));
    }
    int year = Integer.parseInt(yyyy);
    adapter.add(yyyy);
    adapter.add("" + (year + 1));
    spinner.setSelection(0);

}

From source file:com.google.android.gcm.demo.ui.HomeFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
    mLogger = new LoggingService.Logger(getActivity());

    mQuickTests = MainMenu.getTests(getActivity());
    mQuickTestsAdapter = new HintAdapter(getActivity(), android.R.layout.simple_spinner_item,
            new ArrayList<>(mQuickTests.keySet()), getString(R.string.home_quick_test_hint));
    mQuickTestsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    View view = inflater.inflate(R.layout.fragment_home, container, false);
    Spinner quickTests = (Spinner) view.findViewById(R.id.home_quick_test);
    quickTests.setPrompt(getString(R.string.home_quick_test_hint));
    quickTests.setAdapter(mQuickTestsAdapter);
    quickTests.setSelection(mQuickTestsAdapter.getCount());
    quickTests.setOnItemSelectedListener(this);

    view.findViewById(R.id.home_sender_id).setOnClickListener(this);
    view.findViewById(R.id.home_api_key).setOnClickListener(this);
    view.findViewById(R.id.home_destination).setOnClickListener(this);
    view.findViewById(R.id.home_submit).setOnClickListener(this);

    loadSavedState(savedState);/*from w  w w . j ava 2 s. co m*/
    setValueFromFragmentState(view.findViewById(R.id.home_sender_id), SENDER_ID);
    setValueFromFragmentState(view.findViewById(R.id.home_api_key), API_KEY);
    setValueFromFragmentState(view.findViewById(R.id.home_destination), TOKEN);

    return view;
}

From source file:au.org.ala.fielddata.mobile.SurveyBuilder.java

private Spinner buildSpinner(Attribute attribute, ViewGroup parent) {

    ViewGroup row = (ViewGroup) viewContext.getLayoutInflater().inflate(R.layout.input_spinner_view, parent);

    Spinner spinner = (Spinner) row.findViewById(R.id.spinner);
    spinner.setPrompt("Select " + attribute.description);
    ArrayList<AttributeOption> options = new ArrayList<Attribute.AttributeOption>(attribute.options.length + 1);
    options.addAll(Arrays.asList(attribute.options));

    ArrayAdapter<AttributeOption> adapter = new ArrayAdapter<AttributeOption>(viewContext,
            R.layout.multiline_spinner_item, options);
    adapter.setDropDownViewResource(R.layout.multiline_spinner_dropdown_item);
    spinner.setAdapter(adapter);/*from w w w.j  a va 2 s.c  om*/

    return spinner;
}

From source file:org.mifos.androidclient.templates.OperationFormActivity.java

public Spinner addComboBoxFormField(String fieldLabel, List<String> elements) {
    LinearLayout field = (LinearLayout) getLayoutInflater().inflate(R.layout.combo_box_form_field, null);
    TextView label = (TextView) field.findViewById(R.id.comboBoxFormField_label);
    label.setText(fieldLabel);//from  ww w  .  java 2 s .  com
    Spinner input = (Spinner) field.findViewById(R.id.comboBoxFormField_input);
    input.setPrompt(fieldLabel);
    input.setAdapter(new ArrayAdapter(this, R.layout.combo_box_item, elements));
    mFormFields.addView(field, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    return input;
}