Java Code Examples for android.widget.Spinner#setEnabled()
The following examples show how to use
android.widget.Spinner#setEnabled() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java From aedict with GNU General Public License v3.0 | 6 votes |
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { final Activity activity = MainActivity.this; final Spinner matcher = (Spinner) activity.findViewById(R.id.matcher); final CheckBox deinflect = (CheckBox) activity.findViewById(R.id.jpDeinflectVerbs); final CheckBox tanaka = (CheckBox) activity.findViewById(R.id.searchExamples); final CheckBox translate = (CheckBox) activity.findViewById(R.id.translate); if (buttonView.getId() == R.id.jpDeinflectVerbs && isChecked) { matcher.setSelection(MatcherEnum.Exact.ordinal()); tanaka.setChecked(false); translate.setChecked(false); } else if (buttonView.getId() == R.id.searchExamples && isChecked) { matcher.setSelection(MatcherEnum.Substring.ordinal()); deinflect.setChecked(false); translate.setChecked(false); } else if (buttonView.getId() == R.id.translate && isChecked) { deinflect.setChecked(false); tanaka.setChecked(false); } matcher.setEnabled(!deinflect.isChecked() && !tanaka.isChecked() && !translate.isChecked()); findViewById(R.id.englishSearch).setEnabled(!translate.isChecked() && !deinflect.isChecked()); }
Example 2
Source File: DebugView.java From u2020-mvp with Apache License 2.0 | 6 votes |
/** * Populates a {@code Spinner} with the values of an {@code enum} and binds it to the value set * in * the mock service. */ private <T extends Enum<T>> void configureResponseSpinner(Spinner spinner, final Class<T> responseClass) { final EnumAdapter<T> adapter = new EnumAdapter<>(getContext(), responseClass); spinner.setEnabled(isMockMode); spinner.setAdapter(adapter); spinner.setSelection(mockGalleryService.getResponse(responseClass).ordinal()); RxAdapterView.itemSelections(spinner) .map(adapter::getItem) .filter(item -> item != mockGalleryService.getResponse(responseClass)) .subscribe(selected -> { Timber.d("Setting %s to %s", responseClass.getSimpleName(), selected); mockGalleryService.setResponse(responseClass, selected); ProcessPhoenix.triggerRebirth(getContext()); }); }
Example 3
Source File: DebugView.java From u2020 with Apache License 2.0 | 6 votes |
/** * Populates a {@code Spinner} with the values of an {@code enum} and binds it to the value set * in * the mock service. */ private <T extends Enum<T>> void configureResponseSpinner(Spinner spinner, final Class<T> responseClass) { final EnumAdapter<T> adapter = new EnumAdapter<>(getContext(), responseClass); spinner.setEnabled(isMockMode); spinner.setAdapter(adapter); spinner.setSelection(mockResponseSupplier.get(responseClass).ordinal()); RxAdapterView.itemSelections(spinner) .map(adapter::getItem) .filter(item -> item != mockResponseSupplier.get(responseClass)) .subscribe(selected -> { Timber.d("Setting %s to %s", responseClass.getSimpleName(), selected); mockResponseSupplier.set(selected); }); }
Example 4
Source File: FileSelector.java From IPTVFree with Apache License 2.0 | 5 votes |
private void prepareFilterSpinner(String[] fitlesFilter) { mFilterSpinner = (Spinner) mDialog.findViewById(R.id.fileFilter); if (fitlesFilter == null || fitlesFilter.length == 0) { fitlesFilter = new String[] { FileUtils.FILTER_ALLOW_ALL }; mFilterSpinner.setEnabled(false); } ArrayAdapter<String> adapter = new ArrayAdapter<String>(mContext, R.layout.spinner_item, fitlesFilter); mFilterSpinner.setAdapter(adapter); OnItemSelectedListener onItemSelectedListener = new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> aAdapter, View aView, int arg2, long arg3) { TextView textViewItem = (TextView) aView; String filtr = textViewItem.getText().toString(); makeList(mCurrentLocation, filtr); } @Override public void onNothingSelected(AdapterView<?> arg0) { } }; mFilterSpinner.setOnItemSelectedListener(onItemSelectedListener); }
Example 5
Source File: TGHarmonicDialog.java From tuxguitar with GNU Lesser General Public License v2.1 | 5 votes |
public void fillData(int type, int selection) { TGSelectableItem[] selectableItems = createDataValues(type); ArrayAdapter<TGSelectableItem> arrayAdapter = new ArrayAdapter<TGSelectableItem>(getActivity(), android.R.layout.simple_spinner_item, selectableItems); arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); Spinner spinner = (Spinner) this.getView().findViewById(R.id.harmonic_dlg_data_value); spinner.setAdapter(arrayAdapter); spinner.setEnabled(selectableItems.length > 0); spinner.setVisibility(selectableItems.length > 0 ? View.VISIBLE : View.GONE); if( selectableItems.length > 0 ) { spinner.setSelection(arrayAdapter.getPosition(new TGSelectableItem(Integer.valueOf(selection), null))); } }
Example 6
Source File: main_card.java From octodroid with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void onPostExecute(String[][] strings) { try { if (strings[0][0].contains("null")) { final Button right = (Button) rootView.findViewById(R.id.buttonConDis); right.setText("Connect"); right.setEnabled(false); return; } }catch (Exception e){ } ArrayList<String> spinnerArray = new ArrayList<String>(); for (String i : strings[0]){ spinnerArray.add(i.replace("\\/", "/")); } ArrayList<String> spinnerArray2 = new ArrayList<String>(); for (String i2 : strings[1]){ spinnerArray2.add(i2); } LinearLayout layout = new LinearLayout(rootView.getContext()); final Spinner spinner = (Spinner) rootView.findViewById(R.id.spinner); ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(rootView.getContext(), android.R.layout.simple_spinner_dropdown_item, spinnerArray); spinner.setAdapter(spinnerArrayAdapter); spinner.setEnabled(true); final Spinner spinner2 = (Spinner) rootView.findViewById(R.id.spinner2); ArrayAdapter<String> spinnerArrayAdapter2 = new ArrayAdapter<String>(rootView.getContext(), android.R.layout.simple_spinner_dropdown_item, spinnerArray2); spinner2.setAdapter(spinnerArrayAdapter2); spinner2.setEnabled(true); }
Example 7
Source File: AutocompleteTestActivity.java From android-places-demos with Apache License 2.0 | 4 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Use whatever theme was set from the MainActivity - some of these colors (e.g primary color) // will get picked up by the AutocompleteActivity. int theme = getIntent().getIntExtra(MainActivity.THEME_RES_ID_EXTRA, 0); if (theme != 0) { setTheme(theme); } setContentView(R.layout.autocomplete_test_activity); // Retrieve a PlacesClient (previously initialized - see MainActivity) placesClient = Places.createClient(this); // Set up view objects responseView = findViewById(R.id.response); Spinner typeFilterSpinner = findViewById(R.id.autocomplete_type_filter); typeFilterSpinner.setAdapter( new ArrayAdapter<>( this, android.R.layout.simple_list_item_1, Arrays.asList(TypeFilter.values()))); CheckBox useTypeFilterCheckBox = findViewById(R.id.autocomplete_use_type_filter); useTypeFilterCheckBox.setOnCheckedChangeListener( (buttonView, isChecked) -> typeFilterSpinner.setEnabled(isChecked)); fieldSelector = new FieldSelector( findViewById(R.id.use_custom_fields), findViewById(R.id.custom_fields_list), savedInstanceState); setupAutocompleteSupportFragment(); // Set listeners for Autocomplete activity findViewById(R.id.autocomplete_activity_button) .setOnClickListener(view -> startAutocompleteActivity()); // Set listeners for programmatic Autocomplete findViewById(R.id.fetch_autocomplete_predictions_button) .setOnClickListener(view -> findAutocompletePredictions()); // UI initialization setLoading(false); typeFilterSpinner.setEnabled(false); }
Example 8
Source File: AutocompleteTestActivity.java From android-places-demos with Apache License 2.0 | 4 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Use whatever theme was set from the MainActivity - some of these colors (e.g primary color) // will get picked up by the AutocompleteActivity. int theme = getIntent().getIntExtra(MainActivity.THEME_RES_ID_EXTRA, 0); if (theme != 0) { setTheme(theme); } setContentView(R.layout.autocomplete_test_activity); // Retrieve a PlacesClient (previously initialized - see MainActivity) placesClient = Places.createClient(this); // Set up view objects responseView = findViewById(R.id.response); Spinner typeFilterSpinner = findViewById(R.id.autocomplete_type_filter); typeFilterSpinner.setAdapter( new ArrayAdapter<>( this, android.R.layout.simple_list_item_1, Arrays.asList(TypeFilter.values()))); CheckBox useTypeFilterCheckBox = findViewById(R.id.autocomplete_use_type_filter); useTypeFilterCheckBox.setOnCheckedChangeListener( (buttonView, isChecked) -> typeFilterSpinner.setEnabled(isChecked)); fieldSelector = new FieldSelector( findViewById(R.id.use_custom_fields), findViewById(R.id.custom_fields_list), savedInstanceState); setupAutocompleteSupportFragment(); // Set listeners for Autocomplete activity findViewById(R.id.autocomplete_activity_button) .setOnClickListener(view -> startAutocompleteActivity()); // Set listeners for programmatic Autocomplete findViewById(R.id.fetch_autocomplete_predictions_button) .setOnClickListener(view -> findAutocompletePredictions()); // UI initialization setLoading(false); typeFilterSpinner.setEnabled(false); }
Example 9
Source File: DropLogActivity.java From kcanotify_h5-master with GNU General Public License v3.0 | 4 votes |
public void setSpinnerEnable(Spinner sp, boolean b) { if (sp != null) { sp.setEnabled(b); } }
Example 10
Source File: DropLogActivity.java From kcanotify with GNU General Public License v3.0 | 4 votes |
public void setSpinnerEnable(Spinner sp, boolean b) { if (sp != null) { sp.setEnabled(b); } }
Example 11
Source File: TGTrackTuningDialog.java From tuxguitar with GNU Lesser General Public License v2.1 | 4 votes |
public void updateOffset(boolean enabled) { Spinner spinner = (Spinner) this.getView().findViewById(R.id.track_tuning_dlg_offset_value); spinner.setEnabled(enabled); }
Example 12
Source File: SpinnerWidget.java From commcare-android with Apache License 2.0 | 4 votes |
public SpinnerWidget(Context context, FormEntryPrompt prompt) { super(context, prompt); mItems = getSelectChoices(); spinner = new Spinner(context); choices = new String[mItems.size()]; for (int i = 0; i < mItems.size(); i++) { choices[i] = prompt.getSelectChoiceText(mItems.get(i)); } // The spinner requires a custom adapter. It is defined below SpinnerAdapter adapter = new SpinnerAdapter(getContext(), android.R.layout.simple_spinner_item, getChoicesWithEmptyFirstSlot(choices), TypedValue.COMPLEX_UNIT_DIP, mQuestionFontSize); spinner.setAdapter(adapter); spinner.setPrompt(prompt.getQuestionText()); spinner.setEnabled(!prompt.isReadOnly()); spinner.setFocusable(!prompt.isReadOnly()); // Fill in previous answer String s = null; if (prompt.getAnswerValue() != null) { s = ((Selection)prompt.getAnswerValue().getValue()).getValue(); } if (s != null) { for (int i = 0; i < mItems.size(); ++i) { String sMatch = mItems.get(i).getValue(); if (sMatch.equals(s)) { // Workaround to a really weird spinner bug that triggers onItemSelected // in the initial selection of spinner even though no listener is set. // https://stackoverflow.com/a/17336944/6671572 spinner.setSelection(i+1, false); } } } spinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { widgetEntryChanged(); } @Override public void onNothingSelected(AdapterView<?> parent) { //do nothing here } }); addView(spinner); }
Example 13
Source File: ChannelDetailActivity.java From buddycloud-android with Apache License 2.0 | 4 votes |
private void setEditable(boolean editable, Spinner spinner) { if (!editable) { spinner.setEnabled(false); spinner.setClickable(false); } }