List of usage examples for android.widget Spinner setAdapter
@Override public void setAdapter(SpinnerAdapter adapter)
From source file:au.com.wallaceit.reddinator.SubredditSelectActivity.java
private void showMultiEditDialog(final String multiPath) { JSONObject multiObj = global.getSubredditManager().getMultiData(multiPath); @SuppressLint("InflateParams") LinearLayout dialogView = (LinearLayout) getLayoutInflater().inflate(R.layout.dialog_multi_edit, null); // passing null okay for dialog final Button saveButton = (Button) dialogView.findViewById(R.id.multi_save_button); final Button renameButton = (Button) dialogView.findViewById(R.id.multi_rename_button); multiName = (TextView) dialogView.findViewById(R.id.multi_pname); final EditText displayName = (EditText) dialogView.findViewById(R.id.multi_name); final EditText description = (EditText) dialogView.findViewById(R.id.multi_description); final EditText color = (EditText) dialogView.findViewById(R.id.multi_color); final Spinner icon = (Spinner) dialogView.findViewById(R.id.multi_icon); final Spinner visibility = (Spinner) dialogView.findViewById(R.id.multi_visibility); final Spinner weighting = (Spinner) dialogView.findViewById(R.id.multi_weighting); ArrayAdapter<CharSequence> iconAdapter = ArrayAdapter.createFromResource(SubredditSelectActivity.this, R.array.multi_icons, android.R.layout.simple_spinner_item); iconAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); icon.setAdapter(iconAdapter); ArrayAdapter<CharSequence> visibilityAdapter = ArrayAdapter.createFromResource(SubredditSelectActivity.this, R.array.multi_visibility, android.R.layout.simple_spinner_item); visibilityAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); visibility.setAdapter(visibilityAdapter); ArrayAdapter<CharSequence> weightsAdapter = ArrayAdapter.createFromResource(SubredditSelectActivity.this, R.array.multi_weights, android.R.layout.simple_spinner_item); weightsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); weighting.setAdapter(weightsAdapter); try {//from w w w. j av a2 s . co m multiName.setText(multiObj.getString("name")); displayName.setText(multiObj.getString("display_name")); description.setText(multiObj.getString("description_md")); color.setText(multiObj.getString("key_color")); String iconName = multiObj.getString("icon_name"); icon.setSelection(iconAdapter.getPosition(iconName.equals("") ? "none" : iconName)); visibility.setSelection(iconAdapter.getPosition(multiObj.getString("visibility"))); weighting.setSelection(iconAdapter.getPosition(multiObj.getString("weighting_scheme"))); } catch (JSONException e) { e.printStackTrace(); } ViewPager pager = (ViewPager) dialogView.findViewById(R.id.multi_pager); LinearLayout tabsWidget = (LinearLayout) dialogView.findViewById(R.id.multi_tab_widget); pager.setAdapter(new SimpleTabsAdapter(new String[] { "Subreddits", "Settings" }, new int[] { R.id.multi_subreddits, R.id.multi_settings }, SubredditSelectActivity.this, dialogView)); SimpleTabsWidget simpleTabsWidget = new SimpleTabsWidget(SubredditSelectActivity.this, tabsWidget); simpleTabsWidget.setViewPager(pager); ThemeManager.Theme theme = global.mThemeManager.getActiveTheme("appthemepref"); int headerColor = Color.parseColor(theme.getValue("header_color")); int headerText = Color.parseColor(theme.getValue("header_text")); simpleTabsWidget.setBackgroundColor(headerColor); simpleTabsWidget.setTextColor(headerText); simpleTabsWidget.setInidicatorColor(Color.parseColor(theme.getValue("tab_indicator"))); ListView subList = (ListView) dialogView.findViewById(R.id.multi_subredditList); multiSubsAdapter = new SubsListAdapter(SubredditSelectActivity.this, multiPath); subList.setAdapter(multiSubsAdapter); renameButton.getBackground().setColorFilter(headerColor, PorterDuff.Mode.MULTIPLY); renameButton.setTextColor(headerText); renameButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showMultiRenameDialog(multiPath); } }); saveButton.getBackground().setColorFilter(headerColor, PorterDuff.Mode.MULTIPLY); saveButton.setTextColor(headerText); saveButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { System.out.println("Save multi"); JSONObject multiObj = new JSONObject(); try { multiObj.put("decription_md", description.getText().toString()); multiObj.put("display_name", displayName.getText().toString()); multiObj.put("icon_name", icon.getSelectedItem().toString().equals("none") ? "" : icon.getSelectedItem().toString()); multiObj.put("key_color", color.getText().toString()); multiObj.put("subreddits", global.getSubredditManager().getMultiData(multiPath).getJSONArray("subreddits")); multiObj.put("visibility", visibility.getSelectedItem().toString()); multiObj.put("weighting_scheme", weighting.getSelectedItem().toString()); new SubscriptionEditTask(SubscriptionEditTask.ACTION_MULTI_EDIT).execute(multiPath, multiObj); } catch (JSONException e) { e.printStackTrace(); } } }); AlertDialog.Builder builder = new AlertDialog.Builder(SubredditSelectActivity.this); multiDialog = builder.setView(dialogView).show(); }
From source file:nf.frex.android.FrexActivity.java
private void preparePropertiesDialog(final Dialog dialog) { final Registry<Fractal> fractals = Registries.fractals; int fractalTypeIndex = fractals.getIndex(view.getFractalId()); final Spinner fractalTypeSpinner = (Spinner) dialog.findViewById(R.id.fractal_type_spinner); final SeekBar iterationsSeekBar = (SeekBar) dialog.findViewById(R.id.num_iterations_seek_bar); final EditText iterationsEditText = (EditText) dialog.findViewById(R.id.num_iterations_edit_text); final CheckBox juliaModeCheckBox = (CheckBox) dialog.findViewById(R.id.julia_mode_fractal_check_box); final CheckBox decoratedFractal = (CheckBox) dialog.findViewById(R.id.decorated_fractal_check_box); final Button okButton = (Button) dialog.findViewById(R.id.ok_button); final Button cancelButton = (Button) dialog.findViewById(R.id.cancel_button); juliaModeCheckBox.setEnabled(true);//w ww . j a v a 2 s.c o m ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, fractals.getIds()); arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); fractalTypeSpinner.setAdapter(arrayAdapter); fractalTypeSpinner.setSelection(fractalTypeIndex, true); fractalTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View spinnerView, int position, long id) { Fractal fractal = fractals.getValue(position); iterationsEditText.setText(fractal.getDefaultIterMax() + ""); boolean sameFractal = view.getFractalId().equals(fractals.getId(position)); if (!sameFractal) { juliaModeCheckBox.setChecked(false); } juliaModeCheckBox.setEnabled(sameFractal); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); iterationsEditText.setText(view.getIterMax() + "", TextView.BufferType.NORMAL); final double iterationsMin = 1; final double iterationsMax = 3; final SeekBarConfigurer iterationsSeekBarConfigurer = SeekBarConfigurer.create(iterationsSeekBar, iterationsMin, iterationsMax, true, view.getIterMax()); iterationsSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { int iterMax = iterationsSeekBarConfigurer.getValueInt(); iterationsEditText.setText(iterMax + "", TextView.BufferType.NORMAL); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); iterationsEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { try { int iterMax = Integer.parseInt(v.getText().toString()); iterationsSeekBarConfigurer.setValue(iterMax); return true; } catch (NumberFormatException e) { return false; } } }); decoratedFractal.setChecked(view.isDecoratedFractal()); juliaModeCheckBox.setChecked(view.isJuliaModeFractal()); okButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int iterMax; try { iterMax = Integer.parseInt(iterationsEditText.getText().toString()); } catch (NumberFormatException e) { Toast.makeText(FrexActivity.this, getString(R.string.error_msg, e.getLocalizedMessage()), Toast.LENGTH_SHORT).show(); return; } dialog.dismiss(); String oldConfigName = view.getConfigName(); String newFractalId = fractals.getId(fractalTypeSpinner.getSelectedItemPosition()); Fractal fractal = fractals.getValue(fractalTypeSpinner.getSelectedItemPosition()); String oldFractalId = view.getFractalId(); boolean newJuliaModeFractal = juliaModeCheckBox.isChecked(); boolean oldJuliaModeFractal = view.isJuliaModeFractal(); view.setFractalId(newFractalId); view.setIterMax(iterMax); view.setDecoratedFractal(decoratedFractal.isChecked()); view.setJuliaModeFractal(newJuliaModeFractal); boolean fractalTypeChanged = !oldFractalId.equals(newFractalId); if (fractalTypeChanged) { if (oldConfigName.contains(oldFractalId.toLowerCase())) { view.setConfigName(newFractalId.toLowerCase()); } view.setRegion(fractal.getDefaultRegion()); view.setBailOut(fractal.getDefaultBailOut()); } boolean juliaModeChanged = oldJuliaModeFractal != newJuliaModeFractal; if (fractalTypeChanged || juliaModeChanged) { view.getRegionHistory().clear(); view.getRegionHistory().add(fractal.getDefaultRegion().clone()); } view.recomputeAll(); } }); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); }
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); adapter.clear();//from w w w. ja v a 2s. c o m 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); adapter.clear();/*from ww w . j a v a 2 s . com*/ 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 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); 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;/*www.ja v a 2 s . c o m*/ 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 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); adapter.clear();//from w w w .j av a 2s . c om 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 setSpinnerActionType(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_action_type)); spinner.setAdapter(adapter); adapter.clear();//from w w w . ja va 2 s . c o m adapter.add(PROFILE_ACTION_TYPE_ACTIVITY); adapter.add(PROFILE_ACTION_TYPE_BSH_SCRIPT); adapter.add(PROFILE_ACTION_TYPE_COMPARE); adapter.add(PROFILE_ACTION_TYPE_MESSAGE); adapter.add(PROFILE_ACTION_TYPE_MUSIC); adapter.add(PROFILE_ACTION_TYPE_RINGTONE); adapter.add(PROFILE_ACTION_TYPE_TASK); adapter.add(PROFILE_ACTION_TYPE_TIME); adapter.add(PROFILE_ACTION_TYPE_WAIT); // adapter.add(PROFILE_ACTION_TYPE_SCRIPT); 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.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(// w ww . j a v a2s. c o m mGlblParms.context.getString(R.string.msgs_edit_profile_action_select_activity_data_type)); spinner.setAdapter(adapter); 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 setSpinnerActivityDataType(final GlobalParameters mGlblParms, Dialog dialog, Spinner spinner, CustomSpinnerAdapter adapter, String selected) { adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setPrompt(/*from w w w.j a v a 2s . co m*/ mGlblParms.context.getString(R.string.msgs_edit_profile_action_select_activity_data_type)); spinner.setAdapter(adapter); 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 setSpinnerExtraDataType(final GlobalParameters mGlblParms, Dialog dialog, Spinner spinner, CustomSpinnerAdapter adapter, String selected) { adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setPrompt(//from w ww .j ava 2s .c o m mGlblParms.context.getString(R.string.msgs_edit_profile_action_select_activity_data_type)); spinner.setAdapter(adapter); 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); }