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
Stop searching for code, let great code find you!  Add Codota to your java IDE
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
Stop searching for code, let great code find you!  Add Codota to your java IDE
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
Stop searching for code, let great code find you!  Add Codota to your java IDE
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
Stop searching for code, let great code find you!  Add Codota to your java IDE
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
Stop searching for code, let great code find you!  Add Codota to your java IDE

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: