Spinner setAdapter - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spinner setAdapter method.

This code example shows how to use the following methods: getSelectedView, setAdapter
        return this;
    } 
 
    void setContent(SpinnerAdapter adapter, OnNavigationListener listener) {
        mListener = listener;
        mView.setAdapter(adapter);
        refreshSelectedItem(); 
    } 
 
    void setSelected(int position) {
        mView.setSelection(position);
    } 
 
    int getSelected() { 
        return mView.getSelectedItemPosition();
    } 
 
    int getCount() { 
        return mView.getCount();
    } 

9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setAdapter, setOnItemSelectedListener
 
		// XXX 
		mGroupAdapter = new ArrayAdapter<String>(mContext,
				android.R.layout.simple_spinner_item, mGroupList);
		mGroupAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		mGroupSpinner.setAdapter(mGroupAdapter);
		mGroupSpinner.setOnItemSelectedListener(this);
	} 
 
	public String getGroupName() {
		String spinnerItem = mGroupSpinner.getSelectedItem().toString();
		if (spinnerItem.equals(mDefaultGroup)) {
			// return internal representation 
			return ""; 
		} else if (spinnerItem.equals(mAddGroupString)) {
			return mNewGroupInput.getText().toString();
		} else { 
			return spinnerItem;
		} 
	} 
Full Snippet Info
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setAdapter
        languages.add(0, "Default");
 
        SpinnerAdapter adapter = new ArrayAdapter<CharSequence>(this,
                android.R.layout.simple_spinner_item, languages.toArray(
                        new String[languages.size()]));
        mSupportedLanguageView.setAdapter(adapter);
    } 
 
    private void updateLanguagePreference(String language) {
        TextView textView = (TextView) findViewById(R.id.language_preference);
        textView.setText(language);
    } 
 
    /** 
     * Handles the response of the broadcast request about the recognizer supported languages. 
     * 
     * The receiver is required only if the application wants to do recognition in a specific 
     * language. 
     */ 
    private class SupportedLanguageBroadcastReceiver extends BroadcastReceiver {
Full Snippet Info
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setAdapter, getSelectedItem
		assertThat(spinner.getSelectedItem(), nullValue());
	} 
	 
	@Test (expected = IndexOutOfBoundsException.class)	 
	public void getSelectedItemShouldThrowException_EmptyArray(){ 
		spinner.setAdapter(new MyArrayAdapter(context, new String[]{}));
		spinner.getSelectedItem();		
	} 
	 
	@Test 
	public void setSelectionWithAnimatedTransition() {		 
		spinner.setAdapter(arrayAdapter);
		spinner.setSelection(0, true);
		 
		assertThat((String) spinner.getSelectedItem(), equalTo("foo"));
		assertThat((String) spinner.getSelectedItem(), not(equalTo("bar")));
		 
		assertThat(shadowSpinner.isAnimatedTransition(), equalTo(true));
	} 
 
Full Snippet Info
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setSelection, setAdapter, setOnItemSelectedListener
 
		lbl = new TextView(context);
		lbl.setText("Field: ");
		addView(lbl, new LinearLayout.LayoutParams(WIDTH, LayoutParams.WRAP_CONTENT, 1));
 
		spin = new Spinner(context);
		addView(spin, new LinearLayout.LayoutParams(WIDTH, LayoutParams.WRAP_CONTENT, 1));
 
		// Update the value when the edit box changes 
		spin.setOnItemSelectedListener(new OnItemSelectedListener() {
 
			@Override 
			public void onItemSelected(AdapterView<?> arg0, View arg1,
					int arg2, long arg3) {
				value = spin.getSelectedItemPosition();
				if (changeListener != null && localUpdate == false)
					changeListener.run();
			} 
 
			@Override 

7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setSelection, setAdapter
                    getCurrentValue())); 
        } else { 
            int idx = widgetDef.getSelectOptions().getValueIndex(
                    getCurrentValue()); 
            if (idx >= 0) {
                spinner.setSelection(idx);
            } 
        } 
    } 
 
    @Override 
    protected void initCurrentValueFromDocument(Document doc) {
        String value = DocumentAttributeResolver.getString(doc,
                getAttributeName()); 
        setCurrentValue(value);
    } 
 
    @Override 
    public View buildView(LayoutContext context, LayoutMode mode, Document doc,
            List<String> attributeNames, WidgetDefinition widgetDef) {

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setAdapter
		assertEquals( 4, ( (Date) androidWidgetBuilder.getValue( datePicker ) ).getMonth() );
		assertEquals( 9, ( (Date) androidWidgetBuilder.getValue( datePicker ) ).getDate() );
 
		// Spinner 
 
		Spinner spinner = new Spinner( null );
		List<String> lookupList = CollectionUtils.newArrayList( "foo", "bar", "baz" );
		spinner.setAdapter( new LookupArrayAdapter<String>( null, lookupList, null ) );
		assertEquals( "foo", androidWidgetBuilder.getValue( spinner ) );
		androidWidgetBuilder.setValue( "bar", spinner );
		assertEquals( "bar", androidWidgetBuilder.getValue( spinner ) );
	} 
} 
Full Snippet Info
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setAdapter, setOnItemSelectedListener
				nameValueText.getPaddingTop()+5, 
				nameValueText.getPaddingRight()+5, 
				nameValueText.getPaddingBottom());
		addView(nameValueText);
		 
		spinner = new Spinner(context);
//		LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( 
//				LinearLayout.LayoutParams.WRAP_CONTENT,  
//				LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f); 
//		spinner.setLayoutParams(params); 
		addView(spinner);
		spinner.setOnItemSelectedListener(this);
		adapter = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_dropdown_item, values);
		spinner.setAdapter(adapter);
	} 
	 
	private LinkedList<String> values = new LinkedList<String>();
	 
	public void setValues(LinkedList<String> values) {
		this.values = values;
Full Snippet Info
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: getId, setSelection, setAdapter
 
  } 
 
  void setupSpinner(Spinner spinner, ArrayAdapter<?> adapter, int defaultSelection) {
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    int savedSelection = settings.getInt(spinnerPreferenceKey(spinner), defaultSelection);
    if (savedSelection > adapter.getCount() || savedSelection < 0) {
      savedSelection = 0;
    } 
    spinner.setSelection(savedSelection, false);
  } 
 
 
  String spinnerPreferenceKey(final Spinner spinner) {
    return "Spinner" + spinner.getId() + "Position";
  } 
 
 
  void saveSpinnerSetting(SharedPreferences.Editor editor, final Spinner spinner) {
    editor.putInt(spinnerPreferenceKey(spinner), spinner.getSelectedItemPosition());
Full Snippet Info
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setLayoutParams, setAdapter, setOnItemSelectedListener
		label = new TextView(context);
		label.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.75f));
		label.setGravity(Gravity.LEFT);
//		label.setText(""); 
		addView(label);
		picker = new Spinner(context);
		picker.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.25f));
//		picker.setPrompt(""); 
        adapter = new ArrayAdapter<CharSequence>(context, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
//      adapter.add(""); 
		picker.setOnItemSelectedListener(listener);
        picker.setAdapter(adapter);
		addView(picker);
	} 
 
} 
Full Snippet Info
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Spinner setAdapter Questions & Answers:

Other Spinner setAdapter Examples

92:					android.R.layout.simple_spinner_item, lables);
93:	
94:			// Drop down layout style - list view with radio button
95:			spinnerAdapter
96:					.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

Read More

101:	
102:			// attaching data adapter to spinner
103:			spinner.setAdapter(dataAdapter);
104:		}
105:

Read More

40:			// attaching data adapter to spinner
41:			spinner.setAdapter(dataAdapter);
42:	    }
43:	
44:	    @Override

Read More

setAdapter Method Overview
Sets the Adapter used to provide the data which backs this Spinner.
See Code Examples for other Android Spinner Methods: