List of usage examples for android.widget Spinner setPrompt
public void setPrompt(CharSequence prompt)
From source file:com.manning.androidhacks.hack017.CreateAccountAdapter.java
private void populateThirdForm(LinearLayout formLayout) { formLayout.addView(createTitle(mContext.getString(R.string.account_create_city_title))); EditText cityEditText = createEditText(mContext.getString(R.string.account_create_city_hint), InputType.TYPE_CLASS_TEXT, EditorInfo.IME_ACTION_DONE, false, CITY_KEY); if (mFormData.get(CITY_KEY) != null) { cityEditText.setText(mFormData.get(CITY_KEY)); }//w w w . j a va2s . c om formLayout.addView(cityEditText); formLayout.addView(createErrorView(CITY_KEY)); formLayout.addView(createTitle(mContext.getString(R.string.account_create_country_title))); Spinner spinner = new Spinner(mContext); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); params.bottomMargin = 17; spinner.setLayoutParams(params); final ArrayAdapter<String> adapter = new ArrayAdapter<String>(mContext, android.R.layout.simple_spinner_item, Countries.COUNTRIES); spinner.setAdapter(adapter); spinner.setPrompt(mContext.getString(R.string.account_create_country_spinner_prompt)); spinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { mFormData.put(COUNTRY_KEY, Countries.COUNTRY_CODES[pos]); } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); if (mFormData.get(COUNTRY_KEY) != null) { List<String> array = Arrays.asList(Countries.COUNTRY_CODES); spinner.setSelection(array.indexOf(mFormData.get(COUNTRY_KEY))); } formLayout.addView(spinner); }
From source file:com.manning.androidhacks.hack017.CreateAccountAdapter.java
private void populateSecondForm(LinearLayout formLayout) { formLayout.addView(createTitle(mContext.getString(R.string.account_create_password_title))); EditText passwordEditText = createEditText(mContext.getString(R.string.account_create_password_hint), InputType.TYPE_CLASS_TEXT, EditorInfo.IME_ACTION_DONE, false, PASSWORD_KEY); passwordEditText.setTransformationMethod(new PasswordTransformationMethod()); formLayout.addView(passwordEditText); formLayout.addView(createErrorView(PASSWORD_KEY)); formLayout.addView(createTitle(mContext.getString(R.string.account_create_gender_title))); Spinner spinner = new Spinner(mContext); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);//from w ww. j ava 2 s .c o m params.bottomMargin = 17; spinner.setLayoutParams(params); final ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(mContext, R.array.sexes_array, android.R.layout.simple_spinner_item); spinner.setAdapter(adapter); spinner.setPrompt(mContext.getString(R.string.account_create_sex_spinner_prompt)); spinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { mFormData.put(GENDER_KEY, adapter.getItem(pos).toString()); } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); if (mFormData.get(GENDER_KEY) != null) { spinner.setSelection(adapter.getPosition(mFormData.get(GENDER_KEY))); } formLayout.addView(spinner); }
From source file:no.barentswatch.fiskinfo.BaseActivity.java
/** * This function creates a dialog which allows the user to register a item * or tool used./* ww w .jav a 2s .c o m*/ * * @param activityContext * The context of the current activity. */ public void registerItemAndToolUsed(Context activityContext) { LayoutInflater layoutInflater = getLayoutInflater(); View view = layoutInflater.inflate(R.layout.dialog_register_tool, (null)); final AlertDialog builder = new AlertDialog.Builder(activityContext).create(); builder.setTitle(R.string.register_tool_dialog_title); builder.setView(view); final EditText startingCoordinates = (EditText) view.findViewById(R.id.registerStartingCoordinatesOfTool); final EditText endCoordinates = (EditText) view.findViewById(R.id.registerEndCoordinatesOfTool); final TextView invalidInputFeedback = (TextView) view.findViewById(R.id.RegisterToolInvalidInputTextView); if (lastSetStartingPosition != null) { startingCoordinates.setText(lastSetStartingPosition); } if (lastSetEndPosition != null) { endCoordinates.setText(lastSetEndPosition); } final Spinner projectionSpinner = (Spinner) view.findViewById(R.id.projectionChangingSpinner); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.projections, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); projectionSpinner.setPrompt("Velg projeksjon"); projectionSpinner.setAdapter( new NoDefaultSpinner(adapter, R.layout.spinner_layout_select_projection, activityContext)); final Spinner itemSpinner = (Spinner) view.findViewById(R.id.registerMiscType); ArrayAdapter<CharSequence> itemAdapter = ArrayAdapter.createFromResource(this, R.array.tool_types, android.R.layout.simple_spinner_item); itemAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); itemSpinner.setPrompt("Velg redskapstype"); itemSpinner.setAdapter( new NoDefaultSpinner(itemAdapter, R.layout.spinner_layout_choose_tool, activityContext)); Button fetchToolStartingCoordinatesButton = (Button) view .findViewById(R.id.dialogFetchUserStartingCoordinates); Button fetchToolEndCoordinatesButton = (Button) view.findViewById(R.id.dialogFetchUserEndCoordinates); fetchToolStartingCoordinatesButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { setToolCoordinatesPosition(startingCoordinates); } }); fetchToolEndCoordinatesButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { setToolCoordinatesPosition(endCoordinates); } }); acceptButtonRegister(view, builder, startingCoordinates, endCoordinates, invalidInputFeedback, projectionSpinner, itemSpinner); Button cancelButton = (Button) view.findViewById(R.id.DialogCancelRegistration); cancelButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { builder.dismiss(); } }); builder.show(); }
From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceActionProfile.java
final static private void setSpinnerExtraDataBoolean(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_action_select_activity_data_type)); spinner.setAdapter(adapter);/*from w ww. j a va 2s .c o m*/ adapter.clear(); adapter.add("false"); adapter.add("true"); int sel_no = 0; if (selected.equals("true")) sel_no = 1; spinner.setSelection(sel_no); }
From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceActionProfile.java
final static private void setSpinnerCompareResult(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_action_compare_select_type)); spinner.setAdapter(adapter);// w w w. j a v a 2s .c om adapter.clear(); adapter.add(PROFILE_ACTION_TYPE_COMPARE_RESULT_CONTINUE); adapter.add(PROFILE_ACTION_TYPE_COMPARE_RESULT_ABORT); adapter.add(PROFILE_ACTION_TYPE_COMPARE_RESULT_SKIP); for (int i = 0; i < adapter.getCount(); i++) if (adapter.getItem(i).equals(selected)) { spinner.setSelection(i); break; } }
From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceActionProfile.java
final static private void setSpinnerMessageType(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_action_compare_select_type)); spinner.setAdapter(adapter);/*from w ww . j a v a2 s .co m*/ adapter.clear(); adapter.add(PROFILE_ACTION_TYPE_MESSAGE_DIALOG); adapter.add(PROFILE_ACTION_TYPE_MESSAGE_NOTIFICATION); // adapter.add(PROFILE_ACTION_TYPE_MESSAGE_WITHOUT_TEXT); for (int i = 0; i < adapter.getCount(); i++) if (adapter.getItem(i).equals(selected)) { spinner.setSelection(i); break; } }
From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceActionProfile.java
final static private void setSpinnerActivityDataType(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_action_select_activity_data_type)); spinner.setAdapter(adapter);/*from ww w . j a v a 2 s. co m*/ adapter.clear(); adapter.add(PROFILE_ACTION_TYPE_ACTIVITY_DATA_TYPE_NONE); adapter.add(PROFILE_ACTION_TYPE_ACTIVITY_DATA_TYPE_EXTRA); adapter.add(PROFILE_ACTION_TYPE_ACTIVITY_DATA_TYPE_URI); int sel_no = 0; if (selected.equals(PROFILE_ACTION_TYPE_ACTIVITY_DATA_TYPE_EXTRA)) sel_no = 1; else if (selected.equals(PROFILE_ACTION_TYPE_ACTIVITY_DATA_TYPE_URI)) sel_no = 2; spinner.setSelection(sel_no); }
From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceActionProfile.java
final static private void setSpinnerCompareTarget(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_action_compare_select_target)); spinner.setAdapter(adapter);/* w w w. j ava 2s . c o m*/ adapter.clear(); adapter.add(PROFILE_ACTION_TYPE_COMPARE_TARGET_BATTERY); adapter.add(PROFILE_ACTION_TYPE_COMPARE_TARGET_BLUETOOTH); adapter.add(PROFILE_ACTION_TYPE_COMPARE_TARGET_LIGHT); adapter.add(PROFILE_ACTION_TYPE_COMPARE_TARGET_WIFI); adapter.add(PROFILE_ACTION_TYPE_COMPARE_TARGET_TIME); for (int i = 0; i < adapter.getCount(); i++) if (adapter.getItem(i).equals(selected)) { spinner.setSelection(i); break; } }
From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceActionProfile.java
final static private void setSpinnerRingtoneType(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_action_select_ringtone_type)); spinner.setAdapter(adapter);/*from ww w .j av a 2s.c o m*/ adapter.add(PROFILE_ACTION_RINGTONE_TYPE_ALARM); adapter.add(PROFILE_ACTION_RINGTONE_TYPE_NOTIFICATION); adapter.add(PROFILE_ACTION_RINGTONE_TYPE_RINGTONE); int sidx = 0; if (selected.equals(PROFILE_ACTION_RINGTONE_TYPE_ALERT) || selected.equals(PROFILE_ACTION_RINGTONE_TYPE_ALARM)) sidx = 0; else if (selected.equals(PROFILE_ACTION_RINGTONE_TYPE_NOTIFICATION)) sidx = 1; else if (selected.equals(PROFILE_ACTION_RINGTONE_TYPE_RINGTONE)) sidx = 2; spinner.setSelection(sidx); }
From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceActionProfile.java
final static private void setSpinnerExtraDataType(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_action_select_activity_data_type)); spinner.setAdapter(adapter);//from w ww. j a v a 2 s. com adapter.clear(); adapter.add(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_STRING); adapter.add(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_INT); adapter.add(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_BOOLEAN); int sel_no = 0; if (selected.equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_STRING)) sel_no = 0; else if (selected.equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_INT)) sel_no = 1; else sel_no = 2; spinner.setSelection(sel_no); }