Android Spinner - top ranked examples from Open Source projects

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

This code example shows how to use the following methods:getBottom, getLeft, getRight
This code example shows how to use the following methods:getPrompt, setPrompt
        spinner = new Spinner(new Activity());
    } 
 
    @Test 
    public void testPrompt() { 
        spinner.setPrompt("foo");
 
        assertThat(spinner.getPrompt().toString()).isEqualTo("foo");
    } 
} 
7
CodeRank
This code example shows how to use the following methods:getBottom, getLeft, getRight
This code example shows how to use the following methods:setEnabled
	public void setModifiable(boolean enabled) {
		if(enabled)
			button.setVisibility(VISIBLE);
		else 
			button.setVisibility(INVISIBLE);
		spinner.setEnabled(enabled);
	} 
	 
	public void setLast() { 
		selectionExtra = ":";
	} 
	 
	public String getSelection() {
		return spinner.getSelectedItem().toString() + selectionExtra;
	} 
	 
	private void remove() { 
		if(parentView != null)
			parentView.removeView(this);
		if(tagsFragment != null)
6
CodeRank
This code example shows how to use the following methods:
 
    @Before 
    public void setUp() throws Exception { 
        context = new Activity();
        adapterView = new Gallery(context);
		spinner = new Spinner(context);
		shadowSpinner = (ShadowAbsSpinner) Robolectric.shadowOf(spinner);
		String [] testItems = {"foo", "bar"};
		arrayAdapter = new MyArrayAdapter(this.context, testItems);
    } 
 
    @Test 
    public void shouldHaveAdapterViewCommonBehavior() throws Exception { 
        AdapterViewBehavior.shouldActAsAdapterView(adapterView);
    } 
 
	@Test 
	public void checkSetAdapter() { 
		spinner.setAdapter(arrayAdapter);
	} 
6
CodeRank
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 ) );
	} 
} 
7
CodeRank
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
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;
		} 
	} 
7
CodeRank
This code example shows how to use the following methods:getAdapter
    list=(ListView)activity.findViewById(android.R.id.list);
    spinner=(Spinner)activity.findViewById(R.id.spinner);
  } 
   
  public void testSpinnerCount() { 
    assertTrue(spinner.getAdapter().getCount()==3);
  } 
   
  public void testListDefaultCount() { 
    assertTrue(list.getAdapter().getCount()>0);
  } 
} 
7
CodeRank
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

Related Android Spinner Questions & Answers:

Other Android Spinner Examples

19:	        // Spinner element
20:	        Spinner spinner = (Spinner) findViewById(R.id.spinner);
21:	
22:	        // Spinner click listener
23:	        spinner.setOnItemSelectedListener(this);
-
19:	        // Spinner element
20:	        Spinner spinner = (Spinner) findViewById(R.id.spinner);
21:	
22:	        // Spinner click listener
23:	        spinner.setOnItemSelectedListener(this);

Read More

2:		private Button btnAddNewCategory;
3:		private TextView txtCategory;
4:		private Spinner spinnerFood;
5:		// array list for spinner adapter
6:		private ArrayList<Category> categoriesList;
-
19:	
20:			btnAddNewCategory = (Button) findViewById(R.id.btnAddNewCategory);
21:			spinnerFood = (Spinner) findViewById(R.id.spinFood);
22:			txtCategory = (TextView) findViewById(R.id.txtCategory);
23:

Read More

19:	
20:		// Spinner element
21:		Spinner spinner;
22:	
23:		// Add button
-
33:	
34:			// Spinner element
35:			spinner = (Spinner) findViewById(R.id.spinner);
36:	
37:			// add button

Read More

1:	Spinner spinner = (Spinner) findViewById(R.id.spinner);
2:	spinner.setOnItemSelectedListener(this);
3:	
-
1:	Spinner spinner = (Spinner) findViewById(R.id.spinner);
2:	spinner.setOnItemSelectedListener(this);
3:

Read More

1:	Spinner spinner = (Spinner) findViewById(R.id.spinner);
2:	// Create an ArrayAdapter using the string array and a default spinner layout
3:	ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
-
1:	Spinner spinner = (Spinner) findViewById(R.id.spinner);
2:	// Create an ArrayAdapter using the string array and a default spinner layout
3:	ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,

Read More

See Code Examples for Android Spinner Methods: