List of usage examples for android.widget Spinner getAdapter
@Override
public SpinnerAdapter getAdapter()
From source file:com.app.blockydemo.content.bricks.ChangeVariableBrick.java
@Override public void onFinishNewVariableDialog(Spinner spinnerToUpdate, UserVariable newUserVariable) { UserVariableAdapterWrapper userVariableAdapterWrapper = ((UserVariableAdapterWrapper) spinnerToUpdate .getAdapter());//from w w w.jav a 2s. c o m userVariableAdapterWrapper.notifyDataSetChanged(); setSpinnerSelection(spinnerToUpdate, newUserVariable); }
From source file:com.app.blockydemo.content.bricks.ChangeVariableBrick.java
private void setSpinnerSelection(Spinner variableSpinner, UserVariable newUserVariable) { UserVariableAdapterWrapper userVariableAdapterWrapper = (UserVariableAdapterWrapper) variableSpinner .getAdapter();//w ww. ja v a 2 s . c om updateUserVariableIfDeleted(userVariableAdapterWrapper); if (userVariable != null) { variableSpinner.setSelection(userVariableAdapterWrapper.getPositionOfItem(userVariable), true); } else if (newUserVariable != null) { variableSpinner.setSelection(userVariableAdapterWrapper.getPositionOfItem(newUserVariable), true); userVariable = newUserVariable; } else { variableSpinner.setSelection(userVariableAdapterWrapper.getCount() - 1, true); userVariable = userVariableAdapterWrapper.getItem(userVariableAdapterWrapper.getCount() - 1); } }
From source file:org.totschnig.myexpenses.util.Utils.java
public static void selectSpinnerItemByValue(Spinner spnr, long value) { SimpleCursorAdapter adapter = (SimpleCursorAdapter) spnr.getAdapter(); for (int position = 0; position < adapter.getCount(); position++) { if (adapter.getItemId(position) == value) { spnr.setSelection(position); return; }/*from ww w . j ava 2s .c o m*/ } }
From source file:net.majorkernelpanic.spydroid.ClientActivity.java
/** Fetch the current streaming configuration of the remote phone **/ private void getCurrentConfiguration() { new AsyncTask<Void, Void, String>() { @Override/*from w w w . j av a 2 s .com*/ protected String doInBackground(Void... params) { HttpParams httpParameters = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParameters, 3000); HttpConnectionParams.setSoTimeout(httpParameters, 3000); HttpClient client = new DefaultHttpClient(httpParameters); HttpGet request = new HttpGet( "http://" + editTextIP.getText().toString() + ":8080/config.json?get"); ResponseHandler<String> responseHandler = new BasicResponseHandler(); String response = ""; try { response = client.execute(request, responseHandler); } catch (ConnectTimeoutException e) { Log.i(TAG, "Connection timeout ! "); onCompletion(null); } catch (Exception e) { Log.e(TAG, "Could not fetch current configuration on remote device !"); e.printStackTrace(); } return response; } @Override protected void onPostExecute(String response) { try { JSONObject object = (JSONObject) new JSONTokener(response).nextValue(); ((CheckBox) findViewById(R.id.checkbox1)).setChecked(object.getBoolean("streamVideo")); ((CheckBox) findViewById(R.id.checkbox2)).setChecked(object.getBoolean("streamAudio")); for (int spinner : new int[] { R.id.spinner1, R.id.spinner2, R.id.spinner3, R.id.spinner4, R.id.spinner5 }) { Spinner view = (Spinner) findViewById(spinner); SpinnerAdapter adapter = view.getAdapter(); for (int i = 0; i < adapter.getCount(); i++) { Iterator<String> keys = object.keys(); while (keys.hasNext()) { String key = keys.next(); if (adapter.getItem(i).equals(object.get(key))) { view.setSelection(i); } } } } generateURI(); connectToServer(); } catch (Exception e) { stopStreaming(); e.printStackTrace(); } } }.execute(); }
From source file:com.QuarkLabs.BTCeClient.fragments.HomeFragment.java
@Override @SuppressWarnings("unchecked") public void onPriceClicked(String pair, double price) { try {// w w w.jav a 2s . c o m ScrollView scrollView = (ScrollView) getView(); if (scrollView != null) { scrollView.smoothScrollTo(0, scrollView.findViewById(R.id.tradingSection).getBottom()); String[] currencies = pair.split("/"); EditText tradePrice = (EditText) scrollView.findViewById(R.id.TradePrice); tradePrice.setText(String.valueOf(price)); Spinner tradeCurrency = (Spinner) scrollView.findViewById(R.id.TradeCurrency); Spinner tradePriceCurrency = (Spinner) scrollView.findViewById(R.id.TradePriceCurrency); tradeCurrency.setSelection( ((ArrayAdapter<String>) tradeCurrency.getAdapter()).getPosition(currencies[0])); tradePriceCurrency.setSelection( ((ArrayAdapter<String>) tradePriceCurrency.getAdapter()).getPosition(currencies[1])); } } catch (ClassCastException | NullPointerException e) { e.printStackTrace(); } }
From source file:org.catrobat.catroid.content.bricks.BroadcastWaitBrick.java
private void setSpinnerSelection(Spinner spinner) { int position = MessageContainer.getPositionOfMessageInAdapter(broadcastMessage); if (position > 0) { spinner.setSelection(position, true); } else {/*ww w. j a va 2 s .co m*/ if (oldMessage != null && !oldMessage.equals("")) { spinner.setSelection(MessageContainer.getPositionOfMessageInAdapter(oldMessage), true); } else { SpinnerAdapter spinnerAdapter = spinner.getAdapter(); if (spinnerAdapter != null && spinnerAdapter.getCount() > 1) { spinner.setSelection(1, true); } else { spinner.setSelection(0, true); } } } }
From source file:com.cachirulop.moneybox.activity.MovementDetailActivity.java
/** * Load the movements data to the window fields. *///from w ww . j av a2 s.c o m private void initData() { TextView txt; Spinner amount; int pos; _movement = (Movement) getIntent().getExtras().getSerializable("movement"); updateDateAndTime(); amount = (Spinner) findViewById(R.id.sAmount); pos = ((CurrencySpinnerAdapter) amount.getAdapter()).getItemPositionByAmount(_movement.getAmount()); amount.setSelection(pos, true); txt = (TextView) findViewById(R.id.txtDescription); txt.setText(_movement.getDescription()); }
From source file:eu.trentorise.smartcampus.communicator.fragments.messages.AbstractMessageListFragment.java
@SuppressWarnings("unchecked") protected void setupSelectors() { if (hasLabelSelector()) { if (isLabelSelectorEnabled()) { ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); final Spinner labelFilter = (Spinner) getView().findViewById(R.id.messages_spinner_labels); labelFilter.setAdapter(dataAdapter); for (String n : CommunicatorHelper.getLabelsForSelector()) { ((ArrayAdapter<String>) labelFilter.getAdapter()).add(n); }/* w w w . j a v a 2 s . c om*/ labelFilter.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (position == 0 && filter.getLabelId() == null) return; LabelObject selected = null; try { String selectedString = (String) labelFilter.getAdapter().getItem(position); selected = CommunicatorHelper.getLabelByName(selectedString); if (selected != null) { if (selected.getId().equals(filter.getLabelId())) return; filter.setLabelId(selected.getId()); } else filter.setLabelId(null); } catch (Exception e) { labelFilter.setSelection(0); } updateMessageList(); } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); } else { getView().findViewById(R.id.messages_spinner_labels).setEnabled(false); } } else { ((LinearLayout) getView().findViewById(R.id.messages_filters)) .removeView(getView().findViewById(R.id.messages_spinner_labels)); } }
From source file:com.money.manager.ex.investment.watchlist.WatchlistFragment.java
/** * Select the current account in the accounts dropdown. *///w w w . j a va 2 s . com private void selectCurrentAccount() { Spinner spinner = getAccountsSpinner(); if (spinner == null) return; // find account SimpleCursorAdapter adapter = (SimpleCursorAdapter) spinner.getAdapter(); if (adapter == null) return; Cursor cursor = adapter.getCursor(); int position = Constants.NOT_SET; for (int i = 0; i < adapter.getCount(); i++) { cursor.moveToPosition(i); String accountIdString = cursor.getString(cursor.getColumnIndex(Account.ACCOUNTID)); int accountId = Integer.parseInt(accountIdString); if (accountId == getAccountId()) { position = i; break; } } spinner.setSelection(position); }
From source file:systems.soapbox.ombuds.client.ui.WalletActivity.java
private void prepareRestoreWalletDialog(final Dialog dialog) { final AlertDialog alertDialog = (AlertDialog) dialog; final List<File> files = new LinkedList<File>(); // external storage if (Constants.Files.EXTERNAL_WALLET_BACKUP_DIR.exists() && Constants.Files.EXTERNAL_WALLET_BACKUP_DIR.isDirectory()) for (final File file : Constants.Files.EXTERNAL_WALLET_BACKUP_DIR.listFiles()) if (Crypto.OPENSSL_FILE_FILTER.accept(file)) files.add(file);// w w w. j a va 2 s . c o m // internal storage for (final String filename : fileList()) if (filename.startsWith(Constants.Files.WALLET_KEY_BACKUP_PROTOBUF + '.')) files.add(new File(getFilesDir(), filename)); // sort Collections.sort(files, new Comparator<File>() { @Override public int compare(final File lhs, final File rhs) { return lhs.getName().compareToIgnoreCase(rhs.getName()); } }); final View replaceWarningView = alertDialog .findViewById(R.id.restore_wallet_from_storage_dialog_replace_warning); final boolean hasCoins = wallet.getBalance(BalanceType.ESTIMATED).signum() > 0; replaceWarningView.setVisibility(hasCoins ? View.VISIBLE : View.GONE); final Spinner fileView = (Spinner) alertDialog.findViewById(R.id.import_keys_from_storage_file); final FileAdapter adapter = (FileAdapter) fileView.getAdapter(); adapter.setFiles(files); fileView.setEnabled(!adapter.isEmpty()); final EditText passwordView = (EditText) alertDialog.findViewById(R.id.import_keys_from_storage_password); passwordView.setText(null); final ImportDialogButtonEnablerListener dialogButtonEnabler = new ImportDialogButtonEnablerListener( passwordView, alertDialog) { @Override protected boolean hasFile() { return fileView.getSelectedItem() != null; } @Override protected boolean needsPassword() { final File selectedFile = (File) fileView.getSelectedItem(); return selectedFile != null ? Crypto.OPENSSL_FILE_FILTER.accept(selectedFile) : false; } }; passwordView.addTextChangedListener(dialogButtonEnabler); fileView.setOnItemSelectedListener(dialogButtonEnabler); final CheckBox showView = (CheckBox) alertDialog.findViewById(R.id.import_keys_from_storage_show); showView.setOnCheckedChangeListener(new ShowPasswordCheckListener(passwordView)); }