Java Code Examples for android.widget.Spinner#getCount()
The following examples show how to use
android.widget.Spinner#getCount() .
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: TransactionViewActivityTest.java From budget-watch with GNU General Public License v3.0 | 6 votes |
private void checkSpinnerValues(final Activity activity, final int id, List<String> expectedValues) { final View view = activity.findViewById(id); assertNotNull(view); assertTrue(view instanceof Spinner); Spinner spinner = (Spinner)view; Set<String> expectedSet = new HashSet<>(); expectedSet.addAll(expectedValues); LinkedList<String> actualValues = new LinkedList<>(); for(int index = 0; index < spinner.getCount(); index++) { actualValues.add(spinner.getItemAtPosition(index).toString()); } Set<String> actualSet = new HashSet<>(actualValues); assertEquals(expectedSet, actualSet); }
Example 2
Source File: TicketSaveActivity.java From faveo-helpdesk-android-app with Open Software License 3.0 | 5 votes |
private int getIndex(Spinner spinner, String myString) { int index = 0; for (int i = 0; i < spinner.getCount(); i++) { Log.d("item ", spinner.getItemAtPosition(i).toString()); if (spinner.getItemAtPosition(i).toString().equals(myString.trim())) { index = i; break; } } return index; }
Example 3
Source File: MainActivity.java From arcgis-runtime-samples-android with Apache License 2.0 | 5 votes |
/** * Get the position of attribute value * * @param spinner spinner with list of selection options * @param value attribute value * @return position of attribute value */ private int getIndex(Spinner spinner, String value) { if (value == null || spinner.getCount() == 0) { return -1; } else { for (int i = 0; i < spinner.getCount(); i++) { if (spinner.getItemAtPosition(i).toString().equalsIgnoreCase(value)) { return i; } } } return -1; }
Example 4
Source File: EnterTreatment.java From HAPP with GNU General Public License v3.0 | 5 votes |
private static int getIndex(Spinner spinner, String myString){ int index = 0; for (int i=0;i<spinner.getCount();i++){ if (spinner.getItemAtPosition(i).equals(myString)){ index = i; } } return index; }
Example 5
Source File: ShareActivity.java From Shaarlier with GNU General Public License v3.0 | 5 votes |
private void initAccountSpinner() { final Spinner accountSpinner = this.findViewById(R.id.chooseAccount); ArrayAdapter adapter = new ArrayAdapter<>(this, R.layout.tags_list, accounts); accountSpinner.setAdapter(adapter); if(accountSpinner.getCount() < 2) { accountSpinner.setVisibility(View.GONE); } }
Example 6
Source File: DeveloperOptionsDialog.java From PowerSwitch_Android with GNU General Public License v3.0 | 5 votes |
private int getIndex(Spinner spinner, String myString) { int index = 0; for (int i = 0; i < spinner.getCount(); i++) { if (spinner.getItemAtPosition(i).toString().equalsIgnoreCase(myString)) { index = i; break; } } return index; }
Example 7
Source File: SendScreen.java From smartcoins-wallet with MIT License | 5 votes |
private int getSpinnerIndex(Spinner spinner, String assetSymbol) { int index = 0; for (int i = 0; i < spinner.getCount(); i++) { String spString = spinner.getItemAtPosition(i).toString(); spString = spString.replace("bit", ""); if (spString.equalsIgnoreCase(assetSymbol)) { index = i; break; } } return index; }
Example 8
Source File: SettingsDialogActivity.java From medic-gateway with GNU Affero General Public License v3.0 | 5 votes |
private void spinnerVal(int componentId, String val) { Spinner spinner = (Spinner) findViewById(componentId); for(int i=spinner.getCount()-1; i>=0; --i) { if(val.equals(spinner.getItemAtPosition(i).toString())) { spinner.setSelection(i); return; } } }
Example 9
Source File: SettingsFragment.java From m2g_android_miner with GNU General Public License v3.0 | 5 votes |
private void selectSpinnerValue(Spinner spinner, String value) { for (int i = 0; i < spinner.getCount(); i++) { if (spinner.getItemAtPosition(i).toString().equals(value)) { spinner.setSelection(i); break; } } }
Example 10
Source File: Detail.java From faveo-helpdesk-android-app with Open Software License 3.0 | 5 votes |
private int getIndex(Spinner spinner, String myString) { int index = 0; for (int i = 0; i < spinner.getCount(); i++) { Log.d("item ", spinner.getItemAtPosition(i).toString()); if (spinner.getItemAtPosition(i).toString().equals(myString.trim())) { index = i; break; } } return index; }
Example 11
Source File: TranslateActivity.java From Stringlate with MIT License | 5 votes |
private int getItemIndex(Spinner spinner, String str) { if (str == null || str.isEmpty()) return -1; for (int i = 0; i < spinner.getCount(); i++) if (spinner.getItemAtPosition(i).toString().equalsIgnoreCase(str)) return i; return -1; }
Example 12
Source File: DNSFormActivity.java From androdns with Apache License 2.0 | 5 votes |
private int getIndex(Spinner spinner, String myString, int notFoundDefault) { int index = notFoundDefault; for (int i = 0; i < spinner.getCount(); i++) { if (spinner.getItemAtPosition(i).toString().equalsIgnoreCase(myString)) { index = i; break; } } return index; }
Example 13
Source File: MainActivityTest.java From video-transcoder with GNU General Public License v3.0 | 5 votes |
private void setSpinnerSelection(Spinner spinner, String text) { for(int index = 0; index < spinner.getCount(); index++) { String item = spinner.getItemAtPosition(index).toString(); if(item.equals(text)) { spinner.setSelection(index); return; } } fail("Could not find text '" + text + "' in spinner"); }
Example 14
Source File: MainActivity.java From video-transcoder with GNU General Public License v3.0 | 5 votes |
private void setSpinnerSelection(Spinner spinner, Object value) { for(int index = 0; index < spinner.getCount(); index++) { String item = spinner.getItemAtPosition(index).toString(); if(item.equals(value.toString())) { spinner.setSelection(index); break; } } }
Example 15
Source File: MainActivity.java From video-transcoder with GNU General Public License v3.0 | 5 votes |
private void setSpinnerSelection(Spinner spinner, VideoCodec value) { for(int index = 0; index < spinner.getCount(); index++) { VideoCodecWrapper item = (VideoCodecWrapper)spinner.getItemAtPosition(index); if(item.codec == value) { spinner.setSelection(index); break; } } }
Example 16
Source File: TransactionViewActivityTest.java From budget-watch with GNU General Public License v3.0 | 4 votes |
/** * Save an expense and check that the database contains the * expected value */ private void saveExpenseWithArguments(final Activity activity, final String name, final String account, final String budget, final double value, final String note, final String dateStr, final long dateMs, final String expectedReceipt, boolean creatingNewExpense) { DBHelper db = new DBHelper(activity); if(creatingNewExpense) { assertEquals(0, db.getTransactionCount(DBHelper.TransactionDbIds.EXPENSE)); } else { assertEquals(1, db.getTransactionCount(DBHelper.TransactionDbIds.EXPENSE)); } db.close(); final EditText nameField = (EditText) activity.findViewById(R.id.nameEdit); final EditText accountField = (EditText) activity.findViewById(R.id.accountEdit); final EditText valueField = (EditText) activity.findViewById(R.id.valueEdit); final EditText noteField = (EditText) activity.findViewById(R.id.noteEdit); final EditText dateField = (EditText) activity.findViewById(R.id.dateEdit); final Spinner budgetSpinner = (Spinner) activity.findViewById(R.id.budgetSpinner); nameField.setText(name); accountField.setText(account); valueField.setText(Double.toString(value)); noteField.setText(note); dateField.setText(dateStr); // Select the correct budget from the spinner, as there is a blank // item in the first position. for(int index = 0; index < budgetSpinner.getCount(); index++) { String item = budgetSpinner.getItemAtPosition(index).toString(); if(item.equals(budget)) { budgetSpinner.setSelection(index); break; } } assertEquals(budget, budgetSpinner.getSelectedItem().toString()); assertEquals(false, activity.isFinishing()); shadowOf(activity).clickMenuItem(R.id.action_save); assertEquals(true, activity.isFinishing()); assertEquals(1, db.getTransactionCount(DBHelper.TransactionDbIds.EXPENSE)); Transaction transaction = db.getTransaction(1); assertEquals(DBHelper.TransactionDbIds.EXPENSE, transaction.type); assertEquals(name, transaction.description); assertEquals(account, transaction.account); assertEquals(budget, transaction.budget); assertEquals(0, Double.compare(value, transaction.value)); assertEquals(note, transaction.note); assertEquals(dateMs, transaction.dateMs); assertEquals(expectedReceipt, transaction.receipt); }
Example 17
Source File: RipperSimpleType.java From AndroidRipper with GNU Affero General Public License v3.0 | 4 votes |
/** * Detect SimpleType of a Widget * * @param v Widget * @return */ public static String getSimpleType(View v, String type, boolean alreadyCalled) { if (type.endsWith("null")) return NULL; if (type.endsWith("RadioButton")) return RADIO; if (type.endsWith("RadioGroup")) return RADIO_GROUP; if (type.endsWith("CheckBox") || type.endsWith("CheckedTextView")) return CHECKBOX; if (type.endsWith("ToggleButton")) return TOGGLE_BUTTON; if (type.endsWith("MenuDropDownListView") || type.endsWith("IconMenuView") || type.endsWith("ActionMenuView")) return MENU_VIEW; if (type.endsWith("ListMenuItemView") || type.endsWith("IconMenuItemView") || type.endsWith("ActionMenuItemView")) return MENU_ITEM; if (type.endsWith("DatePicker")) return DATE_PICKER; if (type.endsWith("TimePicker")) return TIME_PICKER; if (type.endsWith("DialogTitle")) return DIALOG_VIEW; if (type.endsWith("Button")) return BUTTON; if (type.endsWith("EditText")) return EDIT_TEXT; if (type.endsWith("SearchAutoComplete")) return SEARCH_BAR; if (type.endsWith("Spinner")) { Spinner s = (Spinner)v; if (s.getCount() == 0) return EMPTY_SPINNER; return SPINNER; } if (type.endsWith("SeekBar")) return SEEK_BAR; if (v instanceof RatingBar && (!((RatingBar)v).isIndicator())) return RATING_BAR; if (type.endsWith("TabHost")) return TAB_HOST; //if (type.endsWith("ExpandedMenuView") || type.endsWith("AlertController$RecycleListView")) { return EXPAND_MENU; } if (type.endsWith("ListView") || type.endsWith("ExpandedMenuView")) { ListView l = (ListView)v; if (l.getCount() == 0) return EMPTY_LIST; if (l.getAdapter().getClass().getName().endsWith("PreferenceGroupAdapter")) { return PREFERENCE_LIST; } switch (l.getChoiceMode()) { case ListView.CHOICE_MODE_NONE: return LIST_VIEW; case ListView.CHOICE_MODE_SINGLE: return SINGLE_CHOICE_LIST; case ListView.CHOICE_MODE_MULTIPLE: return MULTI_CHOICE_LIST; } } if (type.endsWith("AutoCompleteTextView")) return AUTOCOMPLETE_TEXTVIEW; if (type.endsWith("TextView")) return TEXT_VIEW; if (type.endsWith("ImageView")) return IMAGE_VIEW; if (type.endsWith("LinearLayout")) return LINEAR_LAYOUT; if (type.endsWith("RelativeLayout")) return RELATIVE_LAYOUT; if (type.endsWith("SlidingDrawer")) return SLIDING_DRAWER; if (type.endsWith("DrawerLayout")) return DRAWER_LAYOUT; if ((v instanceof WebView) || type.endsWith("WebView")) return WEB_VIEW; if (type.endsWith("TwoLineListItem")) return LIST_ITEM; if (type.endsWith("NumberPicker")) return NUMBER_PICKER; if (type.endsWith("NumberPickerButton")) return NUMBER_PICKER_BUTTON; String parentType = v.getClass().getSuperclass().getName(); if (alreadyCalled == false && parentType != null) { System.out.print(">>>>>> " + parentType); return getSimpleType(v, parentType, true); } return ""; }