List of usage examples for android.widget Spinner setAdapter
@Override public void setAdapter(SpinnerAdapter adapter)
From source file:com.garlicg.screenrecord4cm.SettingsActivity.java
/** * Create video size setting view// w w w . j a v a 2 s. c om */ private void createVideoSize(Bundle savedInstanceState) { int vp = mPrefs.getVideoPercentage(); final VideoPercentage[] spinnerItems = AppPrefs.videoPercentages(); int spinnerSelection = AppPrefs.findVideoPercentagePosition(spinnerItems, vp); ArrayAdapter<VideoPercentage> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, spinnerItems); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); final Spinner spinner = ViewFinder.byId(this, R.id.videoPercentageSpinner); spinner.setAdapter(adapter); spinner.setSelection(spinnerSelection); spinner.post(new Runnable() { @Override public void run() { // setSelection later spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (view == null) return; VideoPercentage item = (VideoPercentage) parent.getItemAtPosition(position); new AppPrefs(view.getContext()).saveVideoPercentage(item); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); } }); }
From source file:com.quaap.audiometer.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); pref = getApplicationContext().getSharedPreferences("main", MODE_PRIVATE); mMeterView = (MeterView) findViewById(R.id.meterLayout); mMicLevelReader = new MicLevelReader(this, LevelMethod.dBFS); ImageButton show_ctrls = (ImageButton) findViewById(R.id.show_ctrls); show_ctrls.setOnClickListener(new View.OnClickListener() { @Override//from w ww.j ava 2 s . c om public void onClick(View view) { ViewSwitcher ctrls = (ViewSwitcher) findViewById(R.id.ctrls); ctrls.showNext(); } }); ImageButton hide_ctrls = (ImageButton) findViewById(R.id.hide_ctrls); hide_ctrls.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ViewSwitcher ctrls = (ViewSwitcher) findViewById(R.id.ctrls); ctrls.showPrevious(); } }); final SeekBar scaleCtrl = (SeekBar) findViewById(R.id.scaleCtrl); scaleCtrl.setProgress(pref.getInt("scaleCtrl", scaleCtrl.getProgress())); setScale(); scaleCtrl.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { setScale(); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); final ToggleButton onoff = (ToggleButton) findViewById(R.id.toggleButton); onoff.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (onoff.isChecked()) { if (!startit()) { onoff.setChecked(false); } } else { stopit(); } } }); LevelMethod levM = LevelMethod.valueOf(pref.getString("levelMethod", LevelMethod.dBFS.toString())); final Spinner levelType = (Spinner) findViewById(R.id.levelType); ArrayAdapter<LevelMethod> levelTypeAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, LevelMethod.values()); levelType.setAdapter(levelTypeAdapter); levelType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { LevelMethod lmeth = (LevelMethod) adapterView.getSelectedItem(); levelMethodChanged(lmeth); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); levelType.setSelection(levelTypeAdapter.getPosition(levM)); levelMethodChanged((LevelMethod) levelType.getSelectedItem()); checkMicrophoneAccess(); }
From source file:org.gnucash.android.ui.transaction.SplitEditorFragment.java
/** * Updates the list of possible transfer accounts. * Only accounts with the same currency can be transferred to *///from w ww . jav a 2s . c om private void updateTransferAccountsList(Spinner transferAccountSpinner) { mCursorAdapter = new QualifiedAccountNameCursorAdapter(getActivity(), mCursor); transferAccountSpinner.setAdapter(mCursorAdapter); }
From source file:org.catrobat.catroid.content.bricks.BroadcastReceiverBrick.java
@Override public View getPrototypeView(Context context) { View prototypeView = View.inflate(context, R.layout.brick_broadcast_receive, null); Spinner broadcastReceiverSpinner = (Spinner) prototypeView .findViewById(R.id.brick_broadcast_receive_spinner); broadcastReceiverSpinner.setFocusableInTouchMode(false); broadcastReceiverSpinner.setFocusable(false); broadcastReceiverSpinner.setEnabled(false); SpinnerAdapter broadcastReceiverSpinnerAdapter = MessageContainer.getMessageAdapter(context); broadcastReceiverSpinner.setAdapter(broadcastReceiverSpinnerAdapter); setSpinnerSelection(broadcastReceiverSpinner); return prototypeView; }
From source file:com.andrada.sitracker.ui.SearchActivity.java
private void populateSearchVariants() { Spinner searchOptionSpinner = (Spinner) findViewById(R.id.search_option_spinner); if (searchOptionSpinner != null) { final SearchSpinnerAdapter adapter = new SearchSpinnerAdapter(); adapter.addItem(getString(R.string.search_type_name)); adapter.addItem(getString(R.string.search_type_keyword)); searchOptionSpinner.setAdapter(adapter); searchOptionSpinner.setSelection(mCurrentSearchType); searchOptionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override/* ww w. ja v a 2 s . c o m*/ public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) { if (position >= 0 && position < adapter.getCount()) { onSearchTypeSelected(position); } } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); } }
From source file:com.ntsync.android.sync.activities.ImportActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.import_activity); // Init Source Account Spinner Spinner spinner = (Spinner) findViewById(R.id.sourceAccountSpinner); spinner.setOnItemSelectedListener(this); List<AccountInfo> entries = new ArrayList<AccountInfo>(); sourceAccountAdapter = new AccountAdapter(this, R.layout.twoline_dropdown_item, entries); spinner.setAdapter(sourceAccountAdapter); // Init Destination Account Spinner spinner = (Spinner) findViewById(R.id.destAccountSpinner); spinner.setOnItemSelectedListener(this); destAccountAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item); destAccountAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(destAccountAdapter); initStartContactBtn();/*from w w w.ja va 2 s .c o m*/ }
From source file:com.sakisds.icymonitor.activities.AddNotificationActivity.java
private void setAdapter(Spinner spinner, String[] source) { ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item, source); spinner.setAdapter(adapter); }
From source file:com.esri.arcgisruntime.sample.stretchrenderer.ParametersDialogFragment.java
/** * Builds parameter dialog with values pulled through from MainActivity. * * @param savedInstanceState//from w ww.j a va 2 s . c o m * @return create parameter dialog box */ @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); Bundle stretchParameters = getArguments(); if (stretchParameters != null) { mMin = stretchParameters.getInt("min"); mMax = stretchParameters.getInt("max"); mPercentClipMin = stretchParameters.getInt("percent_clip_min"); mPercentClipMax = stretchParameters.getInt("percent_clip_max"); mStdDevFactor = stretchParameters.getInt("std_dev_factor"); mStretchType = (MainActivity.StretchType) stretchParameters.getSerializable("stretch_type"); } final AlertDialog.Builder paramDialog = new AlertDialog.Builder(getContext()); @SuppressLint("InflateParams") final View dialogView = inflater.inflate(R.layout.stretch_dialog_box, null); paramDialog.setView(dialogView); paramDialog.setTitle(R.string.stretch_rendering_parameters); paramDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); } }); paramDialog.setPositiveButton("Render", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); ParametersListener activity = (ParametersListener) getActivity(); activity.returnParameters(mMin, mMax, mPercentClipMin, mPercentClipMax, mStdDevFactor, mStretchType); } }); // min max ui elements mMinTextView = (TextView) dialogView.findViewById(R.id.min_value_text_view); mMaxTextView = (TextView) dialogView.findViewById(R.id.max_value_text_view); mMinSeekBar = (SeekBar) dialogView.findViewById(R.id.min_seek_bar); mMaxSeekBar = (SeekBar) dialogView.findViewById(R.id.max_seek_bar); mMinSeekBar.setMax(255); mMaxSeekBar.setMax(255); mCurrMinTextView = (TextView) dialogView.findViewById(R.id.curr_min_text_view); mCurrMaxTextView = (TextView) dialogView.findViewById(R.id.curr_max_text_view); updateSeekBar(mMinSeekBar, mMin, mCurrMinTextView); updateSeekBar(mMaxSeekBar, mMax, mCurrMaxTextView); // percent clip ui elements mPercentClipMinTextView = (TextView) dialogView.findViewById(R.id.percent_clip_min_value_text_view); mPercentClipMaxTextView = (TextView) dialogView.findViewById(R.id.percent_clip_max_value_text_view); mPercentClipMinSeekBar = (SeekBar) dialogView.findViewById(R.id.percent_clip_min_seek_bar); mPercentClipMaxSeekBar = (SeekBar) dialogView.findViewById(R.id.percent_clip_max_seek_bar); mPercentClipMinSeekBar.setMax(99); mPercentClipMaxSeekBar.setMax(99); mCurrPercentClipMinTextView = (TextView) dialogView.findViewById(R.id.curr_percent_clip_min_text_view); mCurrPercentClipMaxTextView = (TextView) dialogView.findViewById(R.id.curr_percent_clip_max_text_view); updateSeekBar(mPercentClipMinSeekBar, mPercentClipMin, mCurrPercentClipMinTextView); updateSeekBar(mPercentClipMaxSeekBar, mPercentClipMax, mCurrPercentClipMaxTextView); // standard deviation ui elements mStdDevTextView = (TextView) dialogView.findViewById(R.id.std_dev_text_view); mStdDevSeekBar = (SeekBar) dialogView.findViewById(R.id.std_dev_seek_bar); mStdDevSeekBar.setMax(3); mCurrStdDevTextView = (TextView) dialogView.findViewById(R.id.curr_std_dev_text_view); updateSeekBar(mStdDevSeekBar, mStdDevFactor, mCurrStdDevTextView); // set ui to previous selection if (mStretchType == MainActivity.StretchType.MIN_MAX) { setMinMaxVisibility(true); setPercentClipVisibility(false); setStdDevVisibility(false); } else if (mStretchType == MainActivity.StretchType.PERCENT_CLIP) { setMinMaxVisibility(false); setPercentClipVisibility(true); setStdDevVisibility(false); } else if (mStretchType == MainActivity.StretchType.STANDARD_DEVIATION) { setMinMaxVisibility(false); setPercentClipVisibility(false); setStdDevVisibility(true); } // seek bar listeners mMinSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mMin = progress; updateSeekBar(mMinSeekBar, mMin, mCurrMinTextView); // move max to march min if max goes below min if (mMax < mMin) { mMax = mMin; updateSeekBar(mMaxSeekBar, mMax, mCurrMaxTextView); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mMaxSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mMax = progress; updateSeekBar(mMaxSeekBar, mMax, mCurrMaxTextView); // move min to match max if min goes above max if (mMin > mMax) { mMin = mMax; updateSeekBar(mMinSeekBar, mMin, mCurrMinTextView); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mPercentClipMinSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mPercentClipMin = progress; updateSeekBar(mPercentClipMinSeekBar, mPercentClipMin, mCurrPercentClipMinTextView); if (mPercentClipMin + mPercentClipMax > 100) { // constrain min + max <= 100 mPercentClipMax = 100 - mPercentClipMin; updateSeekBar(mPercentClipMaxSeekBar, mPercentClipMax, mCurrPercentClipMaxTextView); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mPercentClipMaxSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mPercentClipMax = progress; updateSeekBar(mPercentClipMaxSeekBar, mPercentClipMax, mCurrPercentClipMaxTextView); if (mPercentClipMin + mPercentClipMax > 100) { // constrain min + max <= 100 mPercentClipMin = 100 - mPercentClipMax; updateSeekBar(mPercentClipMinSeekBar, mPercentClipMin, mCurrPercentClipMinTextView); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mStdDevSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mStdDevFactor = progress; updateSeekBar(mStdDevSeekBar, mStdDevFactor, mCurrStdDevTextView); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); // stretch type spinner List<String> stretchTypeArray = new ArrayList<>(); stretchTypeArray.add(MainActivity.StretchType.MIN_MAX.toString()); //ordinals:0 stretchTypeArray.add(MainActivity.StretchType.PERCENT_CLIP.toString()); //1 stretchTypeArray.add(MainActivity.StretchType.STANDARD_DEVIATION.toString()); //2 ArrayAdapter<String> stretchTypeSpinnerAdapter = new ArrayAdapter<>(getContext(), R.layout.stretch_spinner_text_view, stretchTypeArray); Spinner stretchTypeSpinner = (Spinner) dialogView.findViewById(R.id.stretch_type_spinner); stretchTypeSpinner.setAdapter(stretchTypeSpinnerAdapter); stretchTypeSpinner.setSelection(mStretchType.ordinal()); stretchTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: mStretchType = MainActivity.StretchType.MIN_MAX; setMinMaxVisibility(true); setPercentClipVisibility(false); setStdDevVisibility(false); break; case 1: mStretchType = MainActivity.StretchType.PERCENT_CLIP; setMinMaxVisibility(false); setPercentClipVisibility(true); setStdDevVisibility(false); break; case 2: mStretchType = MainActivity.StretchType.STANDARD_DEVIATION; setMinMaxVisibility(false); setPercentClipVisibility(false); setStdDevVisibility(true); break; } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); return paramDialog.create(); }
From source file:de.unipassau.isl.evs.ssh.app.activity.EditUserDeviceFragment.java
/** * Creates and shows a dialogs that gives the user the option to edit a group. *//*from w w w . ja v a2s . c om*/ private void showEditUserDeviceDialog(Bundle bundle) { final UserDevice userDevice = (UserDevice) bundle.getSerializable(EDIT_USERDEVICE_DIALOG); if (userDevice == null) { Log.i(TAG, "No device found."); return; } final String[] groupNames = bundle.getStringArray(ALL_GROUPS_DIALOG); if (groupNames == null) { Log.i(TAG, "Empty bundle"); return; } final AppUserConfigurationHandler handler = getComponent(AppUserConfigurationHandler.KEY); if (handler == null) { Log.i(TAG, "Container not yet connected!"); return; } final LayoutInflater inflater = getActivity().getLayoutInflater(); final View dialogView = inflater.inflate(R.layout.dialog_edituserdevice, null); final TextView title = (TextView) dialogView.findViewById(R.id.editdevicedialog_title); title.setText(String.format(getResources().getString(R.string.edit_user_device), userDevice.getName())); final EditText userDeviceName = (EditText) dialogView.findViewById(R.id.editdevicedialog_username); userDeviceName.setText(userDevice.getName()); final ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item, groupNames); final Spinner groupName = ((Spinner) dialogView.findViewById(R.id.editdevicedialog_spinner)); groupName.setAdapter(adapter); groupName.setSelection(adapter.getPosition(userDevice.getInGroup())); final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final Resources res = getResources(); final AlertDialog editDialog = builder.setView(dialogView).setNegativeButton(R.string.cancel, null) .setPositiveButton(R.string.edit, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { final AppMainActivity activity = (AppMainActivity) getActivity(); if (activity.hasPermission(Permission.CHANGE_USER_NAME) && activity.hasPermission(Permission.CHANGE_USER_GROUP)) { String name = userDeviceName.getText().toString(); String group = ((String) groupName.getSelectedItem()); DeviceID userDeviceID = userDevice.getUserDeviceID(); // no permission check as method only gets called when user can edit user name / user group handler.setUserName(userDeviceID, name); handler.setUserGroup(userDeviceID, group); } else { showToast(R.string.you_can_not_edit_user_devices); } } }).setNeutralButton(R.string.remove, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (((AppMainActivity) getActivity()).hasPermission(Permission.DELETE_USER)) { handler.removeUserDevice(userDevice.getUserDeviceID()); String toastText = String.format(res.getString(R.string.device_removed), userDevice.getName()); Toast.makeText(getActivity(), toastText, Toast.LENGTH_SHORT).show(); } else { showToast(R.string.you_can_not_remove_users); } } }).create(); // open the soft keyboard when dialog gets focused userDeviceName.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { editDialog.getWindow() .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } } }); editDialog.show(); userDeviceName.requestFocus(); }
From source file:org.gnucash.android.ui.transaction.dialog.SplitEditorDialogFragment.java
/** * Updates the list of possible transfer accounts. * Only accounts with the same currency can be transferred to *//*from www . ja v a2s. c o m*/ private void updateTransferAccountsList(Spinner transferAccountSpinner) { mCursorAdapter = new QualifiedAccountNameCursorAdapter(getActivity(), android.R.layout.simple_spinner_item, mCursor); mCursorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); transferAccountSpinner.setAdapter(mCursorAdapter); }