List of usage examples for android.widget AdapterView getSelectedItem
public Object getSelectedItem()
From source file:net.kjmaster.cookiemom.settings.SettingsFragment.java
private void createHooks() { setting_custom_cookie_check.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override//from w ww .j a v a 2 s . co m public void onCheckedChanged(CompoundButton compoundButton, boolean b) { iSettings.useCustomCookies().put(b); setting_cookie_list.setEnabled(b); settings_edit_cookie.setEnabled(b); setting_save_cookie.setEnabled(b); if (!b) { String[] cookies = getResources().getStringArray(R.array.cookie_names_array); if (!TextUtils.join(",", cookies).equals(iSettings.CookieList().get())) { for (int i = 0; i < Constants.CookieTypes.length; i++) { String cookieType = Constants.CookieTypes[i]; SettingsActivity settingsActivity = (SettingsActivity) getActivity(); settingsActivity.SaveCookie(cookieType, cookies[i]); } } } } }); settings_auot_fill_cases_check.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { iSettings.useAutoFillCases().put(b); } }); setting_cookie_list.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { settings_edit_cookie.setEnabled(true); if (adapterView.getSelectedItem() != null) { itemSelected = adapterView.getSelectedItem().toString(); } } @Override public void onNothingSelected(AdapterView<?> adapterView) { settings_edit_cookie.setEnabled(false); } }); }
From source file:com.QuarkLabs.BTCeClient.fragments.OrdersBookFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mPairsSpinner = (Spinner) LayoutInflater.from(getActivity()).inflate(R.layout.spinner, null); mPairsSpinner.setAdapter(new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.ExchangePairs))); //restoring spinner position if (savedInstanceState != null) { mPairsSpinner.setSelection(savedInstanceState.getInt("position")); }/*w w w. j a va 2 s. c o m*/ mPairsSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { String selected = parent.getSelectedItem().toString(); Bundle bundle = new Bundle(); bundle.putString("pair", selected); if (mFragmentOpenedFirstTime) { getLoaderManager().initLoader(LOADER_ID, bundle, OrdersBookFragment.this); mFragmentOpenedFirstTime = false; } else { getLoaderManager().restartLoader(LOADER_ID, bundle, OrdersBookFragment.this); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); mAsksAdapter = new OrdersBookAdapter(getActivity()); mBidsAdapter = new OrdersBookAdapter(getActivity()); }
From source file:ch.berta.fabio.popularmovies.presentation.ui.activities.MovieGridActivity.java
private void setupSorting() { mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); int sortSelected = mSharedPrefs.getInt(PERSIST_SORT, 0); Sort[] sortOptions = new Sort[] { new Sort(Sort.SORT_POPULARITY, getString(R.string.sort_popularity)), new Sort(Sort.SORT_RATING, getString(R.string.sort_rating)), new Sort(Sort.SORT_RELEASE_DATE, getString(R.string.sort_release_date)), new Sort(Sort.SORT_FAVORITE, getString(R.string.sort_favorite)) }; ArrayAdapter<Sort> spinnerAdapter = new ArrayAdapter<>(this, R.layout.spinner_item_toolbar, sortOptions); spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mBinding.spGridSort.setAdapter(spinnerAdapter); mBinding.spGridSort.setSelection(sortSelected, false); mBinding.spGridSort.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override//from w w w . java2 s . co m public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { onSortOptionSelected((Sort) parent.getSelectedItem(), position); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); }
From source file:com.microsoft.identity.client.testapp.AcquireTokenFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_acquire, container, false); mAuthority = view.findViewById(R.id.authorityType); mLoginhint = view.findViewById(R.id.loginHint); mUiBehavior = view.findViewById(R.id.uiBehavior); mUserAgent = view.findViewById(R.id.auth_user_agent); mScope = view.findViewById(R.id.scope); mExtraScope = view.findViewById(R.id.extraScope); mEnablePII = view.findViewById(enablePII); mForceRefresh = view.findViewById(R.id.forceRefresh); mDefaultBrowser = view.findViewById(R.id.default_browser); mSelectAccount = view.findViewById(R.id.select_user); mGetUsers = view.findViewById(R.id.btn_getUsers); mClearCache = view.findViewById(R.id.btn_clearCache); mAcquireToken = view.findViewById(R.id.btn_acquiretoken); mAcquireTokenSilent = view.findViewById(R.id.btn_acquiretokensilent); bindSpinnerChoice(mAuthority, Constants.AuthorityType.class); bindSpinnerChoice(mUiBehavior, UiBehavior.class); bindSpinnerChoice(mUserAgent, Constants.UserAgent.class); mAcquireToken.setOnClickListener(new View.OnClickListener() { @Override/*from w w w .jav a 2 s .c o m*/ public void onClick(View v) { mOnFragmentInteractionListener.onAcquireTokenClicked(getCurrentRequestOptions()); } }); mAcquireTokenSilent.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mSelectAccount.getSelectedItem() != null) { mLoginhint.setText(mSelectAccount.getSelectedItem().toString()); } mOnFragmentInteractionListener.onAcquireTokenSilentClicked(getCurrentRequestOptions()); } }); mSelectAccount.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (parent.getSelectedItem() != null) { mLoginhint.setText(parent.getSelectedItem().toString()); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); mGetUsers.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mOnFragmentInteractionListener.onGetUser(); } }); mClearCache.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String accountToRemove = null; if (mSelectAccount.getSelectedItem() != null) { accountToRemove = mSelectAccount.getSelectedItem().toString(); } mOnFragmentInteractionListener.onRemoveUserClicked(accountToRemove); } }); return view; }
From source file:cat.wuyingren.rorhelper.fragments.dialogs.ManageSenatorDialogFragment.java
@NonNull @Override//from w w w. j a va 2 s. c o m public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); LayoutInflater inflater = getActivity().getLayoutInflater(); final View v = inflater.inflate(R.layout.dialog_managesenator, null); final TextView randomKillTitle = (TextView) v.findViewById(R.id.managesenator_randomTitle); final ToggleButton randomKillButton = (ToggleButton) v.findViewById(R.id.managesenator_randomToggle); final LinearLayout selectors = (LinearLayout) v.findViewById(R.id.managesenator_selectors); dataSource = MainActivity.getDataSource(); context = MainActivity.getContext(); currentGameId = getArguments().getLong(ARG_GAMEID); killMode = getArguments().getBoolean(ARG_MODE); statesman = getArguments().getBoolean(ARG_TYPE); result.setKill(killMode); result.setStatesman(statesman); final Spinner senatorSpinner = (Spinner) v.findViewById(R.id.managesenator_senatorSpinner); randomKillButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { result.setRandomKill(isChecked); if (isChecked) { selectors.setVisibility(View.GONE); } else { selectors.setVisibility(View.VISIBLE); } } }); if (!killMode) { randomKillTitle.setVisibility(View.GONE); randomKillButton.setVisibility(View.GONE); String[] keys = getArguments().getStringArray(ARG_ARRAY); ArrayList<String> values = getArguments().getStringArrayList(ARG_VALUES); /*ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(MainActivity.getContext(), android.R.layout.simple_spinner_item, keys);*/ SenatorAdapter adapter = new SenatorAdapter(MainActivity.getContext(), android.R.layout.simple_spinner_item, keys, values); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); senatorSpinner.setAdapter(adapter); } else { randomKillTitle.setVisibility(View.VISIBLE); randomKillButton.setVisibility(View.VISIBLE); } senatorSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { result.setSenatorID(parent.getSelectedItem().toString()); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); final Spinner factionSpinner = SystemUtils.configureSpinner(v, R.id.managesenator_factionSpinner, R.array.faction_nameID); factionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { long factionID = dataSource.getFactionId(currentGameId, getResources().getStringArray(R.array.faction_nameID)[position]); result.setFactionID(factionID); if (killMode) { ArrayList<Senator> senators = dataSource.getAllSenatorsOfFaction(factionID); Iterator<Senator> ite = senators.iterator(); ArrayList<CharSequence> array = new ArrayList<CharSequence>(); ArrayList<String> values = new ArrayList<String>(); while (ite.hasNext()) { Senator s = ite.next(); array.add(String.valueOf(s.getId())); values.add(String.valueOf(s.getName())); } String[] keys = new String[array.size()]; keys = array.toArray(keys); //ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(context, android.R.layout.simple_spinner_item, array); SenatorAdapter adapter = new SenatorAdapter(context, android.R.layout.simple_spinner_item, keys, values); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); senatorSpinner.setAdapter(adapter); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); builder.setView(v).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mListener.onManageSenatorDialogPositiveClick(result); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { getDialog().cancel(); } }); String stringA, stringB; if (killMode) { stringA = getString(R.string.dialog_managesenator_kill_title); } else { stringA = getString(R.string.dialog_managesenator_title); } if (statesman) { stringB = getString(R.string.statesman); } else { stringB = getString(R.string.senator); } builder.setTitle(stringA + " " + stringB); return builder.create(); }
From source file:net.wespot.pim.utils.layout.NoticeDialogFragment.java
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { parent.getItemAtPosition(position);/* w ww. j a va 2 s.com*/ audio = false; video = false; image = false; text = false; number = false; if (parent.getSelectedItem().equals("Audio")) { audio = true; } if (parent.getSelectedItem().equals("Video")) { video = true; } if (parent.getSelectedItem().equals("Picture")) { image = true; } if (parent.getSelectedItem().equals("Text")) { text = true; } if (parent.getSelectedItem().equals("Number")) { number = true; } }
From source file:com.quaap.audiometer.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); pref = getApplicationContext().getSharedPreferences("main", MODE_PRIVATE); mMeterView = (MeterView) findViewById(R.id.meterLayout); mMicLevelReader = new MicLevelReader(this, LevelMethod.dBFS); ImageButton show_ctrls = (ImageButton) findViewById(R.id.show_ctrls); show_ctrls.setOnClickListener(new View.OnClickListener() { @Override//from www.j a va 2 s . c om public void onClick(View view) { ViewSwitcher ctrls = (ViewSwitcher) findViewById(R.id.ctrls); ctrls.showNext(); } }); ImageButton hide_ctrls = (ImageButton) findViewById(R.id.hide_ctrls); hide_ctrls.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ViewSwitcher ctrls = (ViewSwitcher) findViewById(R.id.ctrls); ctrls.showPrevious(); } }); final SeekBar scaleCtrl = (SeekBar) findViewById(R.id.scaleCtrl); scaleCtrl.setProgress(pref.getInt("scaleCtrl", scaleCtrl.getProgress())); setScale(); scaleCtrl.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { setScale(); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); final ToggleButton onoff = (ToggleButton) findViewById(R.id.toggleButton); onoff.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (onoff.isChecked()) { if (!startit()) { onoff.setChecked(false); } } else { stopit(); } } }); LevelMethod levM = LevelMethod.valueOf(pref.getString("levelMethod", LevelMethod.dBFS.toString())); final Spinner levelType = (Spinner) findViewById(R.id.levelType); ArrayAdapter<LevelMethod> levelTypeAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, LevelMethod.values()); levelType.setAdapter(levelTypeAdapter); levelType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { LevelMethod lmeth = (LevelMethod) adapterView.getSelectedItem(); levelMethodChanged(lmeth); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); levelType.setSelection(levelTypeAdapter.getPosition(levM)); levelMethodChanged((LevelMethod) levelType.getSelectedItem()); checkMicrophoneAccess(); }
From source file:org.thezero.qrfi.SuperAwesomeCardFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView; if (position == 0) { rootView = inflater.inflate(R.layout.fragment_generate, container, false); final CardView cardQr = (CardView) rootView.findViewById(R.id.card_qr); cardQr.setVisibility(View.GONE); String[] items = new String[] { "Open", "WEP", "WPA/WPA2" }; final EditText ssid = (EditText) rootView.findViewById(R.id.edit_ssid); final EditText pass = (EditText) rootView.findViewById(R.id.edit_pass); final Spinner spinner = (Spinner) rootView.findViewById(R.id.wifi_type); ArrayAdapter<String> adapter = new ArrayAdapter<>(c, android.R.layout.simple_spinner_item, items); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter);/*from www . j a v a 2s . c om*/ spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (parent.getSelectedItem().toString().equals("Open")) { rootView.findViewById(R.id.second).setVisibility(View.GONE); } else { rootView.findViewById(R.id.second).setVisibility(View.VISIBLE); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); final boolean[] cardHide = { true }; Button delete = (Button) rootView.findViewById(R.id.delete); delete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { cardHide[0] = true; cardQr.animate().translationY(0).alpha(0.0f).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); if (cardHide[0]) cardQr.setVisibility(View.GONE); } }); ssid.setText(""); pass.setText(""); spinner.setSelection(0); } }); Button gen = (Button) rootView.findViewById(R.id.generate); gen.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // WIFI:S:Pistol;T:WEP;P:pistolawifi2;; if (pass.getText().length() < 8 && !spinner.getSelectedItem().toString().equals("Open")) { Toast.makeText(c, c.getString(R.string.error_pass), Toast.LENGTH_LONG).show(); return; } String ap = "WIFI:S:" + ssid.getText() + ";T:" + spinner.getSelectedItem().toString() + ";P:" + pass.getText() + ";;"; Log.d(TAG, ap); QRCodeWriter writer = new QRCodeWriter(); try { BitMatrix matrix = writer.encode(ap, BarcodeFormat.QR_CODE, 700, 700, null); int height = matrix.getHeight(); int width = matrix.getWidth(); final Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { bmp.setPixel(x, y, matrix.get(x, y) ? Color.BLACK : Color.WHITE); } } ImageView qr_image = (ImageView) rootView.findViewById(R.id.qrimage); qr_image.setImageBitmap(bmp); cardHide[0] = false; cardQr.setVisibility(View.VISIBLE); cardQr.setAlpha(1.0f); cardQr.animate().translationY(10).alpha(1.0f); Button dialogButton = (Button) rootView.findViewById(R.id.ok); dialogButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { File sdcard = Environment.getExternalStorageDirectory(); FileOutputStream out = null; File check = new File(sdcard, "/wifipv/"); if (!(check.exists())) { boolean resu = check.mkdir(); if (!resu) { return; } } try { File myFile = new File(sdcard, "/wifipv/" + ssid.getText() + ".png"); out = new FileOutputStream(myFile); boolean success = bmp.compress(Bitmap.CompressFormat.PNG, 100, out); if (success) { MediaScannerConnection.scanFile(c, new String[] { myFile.getAbsolutePath() }, null, new MediaScannerConnection.OnScanCompletedListener() { @Override public void onScanCompleted(String path, Uri uri) { Log.d(TAG, "file " + path + " was scanned seccessfully: " + uri); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.setType("image/png"); shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); Intent new_intent = Intent.createChooser(shareIntent, c.getText(R.string.send_to)); new_intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); c.startActivity(new_intent); } }); } else { Toast.makeText(c, c.getString(R.string.error_share), Toast.LENGTH_LONG) .show(); } } catch (FileNotFoundException e) { e.printStackTrace(); } finally { if (out != null) try { out.close(); } catch (IOException e) { e.printStackTrace(); } } } }); } catch (WriterException e) { e.printStackTrace(); } } }); } else { rootView = inflater.inflate(R.layout.fragment_scan, container, false); Button scan = (Button) rootView.findViewById(R.id.scan); scan.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent myIntent = new Intent(c, ScanActivity.class); myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); c.startActivity(myIntent); } }); Button gallery = (Button) rootView.findViewById(R.id.gallery); gallery.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { selectFromGallery(); } }); /*final boolean[] tutorialHide = {false}; final CardView tutorial = (CardView)rootView.findViewById(R.id.card_tutorial); tutorial.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if(tutorialHide[0]){ tutorialHide[0]=false; Animation anidelta = new ResizeAnimation(tutorial, tutorial.getHeight()); anidelta.setDuration(500); anidelta.setFillAfter(true); tutorial.startAnimation(anidelta); }else{ tutorialHide[0]=true; Animation anidelta = new ResizeAnimation(tutorial, 120); anidelta.setDuration(500); anidelta.setFillAfter(true); tutorial.startAnimation(anidelta); } } });*/ } ViewCompat.setElevation(rootView, 50); return rootView; }
From source file:org.sufficientlysecure.keychain.ui.dialog.AddSubkeyDialogFragment.java
@NonNull @Override// w ww. j a va 2 s . c om public Dialog onCreateDialog(Bundle savedInstanceState) { final FragmentActivity context = getActivity(); final LayoutInflater mInflater; mWillBeMasterKey = getArguments().getBoolean(ARG_WILL_BE_MASTER_KEY); mInflater = context.getLayoutInflater(); CustomAlertDialogBuilder dialog = new CustomAlertDialogBuilder(context); @SuppressLint("InflateParams") View view = mInflater.inflate(R.layout.add_subkey_dialog, null); dialog.setView(view); mNoExpiryCheckBox = (CheckBox) view.findViewById(R.id.add_subkey_no_expiry); mExpiryRow = (TableRow) view.findViewById(R.id.add_subkey_expiry_row); mExpiryDatePicker = (DatePicker) view.findViewById(R.id.add_subkey_expiry_date_picker); mKeyTypeSpinner = (Spinner) view.findViewById(R.id.add_subkey_type); mUsageRadioGroup = (RadioGroup) view.findViewById(R.id.add_subkey_usage_group); mUsageNone = (RadioButton) view.findViewById(R.id.add_subkey_usage_none); mUsageSign = (RadioButton) view.findViewById(R.id.add_subkey_usage_sign); mUsageEncrypt = (RadioButton) view.findViewById(R.id.add_subkey_usage_encrypt); mUsageSignAndEncrypt = (RadioButton) view.findViewById(R.id.add_subkey_usage_sign_and_encrypt); if (mWillBeMasterKey) { dialog.setTitle(R.string.title_change_master_key); mUsageNone.setVisibility(View.VISIBLE); mUsageNone.setChecked(true); } else { dialog.setTitle(R.string.title_add_subkey); } mNoExpiryCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { mExpiryRow.setVisibility(View.GONE); } else { mExpiryRow.setVisibility(View.VISIBLE); } } }); // date picker works based on default time zone Calendar minDateCal = Calendar.getInstance(TimeZone.getDefault()); minDateCal.add(Calendar.DAY_OF_YEAR, 1); // at least one day after creation (today) mExpiryDatePicker.setMinDate(minDateCal.getTime().getTime()); { ArrayList<Choice<SupportedKeyType>> choices = new ArrayList<>(); choices.add(new Choice<>(SupportedKeyType.RSA_2048, getResources().getString(R.string.rsa_2048), getResources().getString(R.string.rsa_2048_description_html))); choices.add(new Choice<>(SupportedKeyType.RSA_3072, getResources().getString(R.string.rsa_3072), getResources().getString(R.string.rsa_3072_description_html))); choices.add(new Choice<>(SupportedKeyType.RSA_4096, getResources().getString(R.string.rsa_4096), getResources().getString(R.string.rsa_4096_description_html))); choices.add(new Choice<>(SupportedKeyType.ECC_P256, getResources().getString(R.string.ecc_p256), getResources().getString(R.string.ecc_p256_description_html))); choices.add(new Choice<>(SupportedKeyType.ECC_P521, getResources().getString(R.string.ecc_p521), getResources().getString(R.string.ecc_p521_description_html))); TwoLineArrayAdapter adapter = new TwoLineArrayAdapter(context, android.R.layout.simple_spinner_item, choices); mKeyTypeSpinner.setAdapter(adapter); // make RSA 3072 the default for (int i = 0; i < choices.size(); ++i) { if (choices.get(i).getId() == SupportedKeyType.RSA_3072) { mKeyTypeSpinner.setSelection(i); break; } } } dialog.setCancelable(true); // onClickListener are set in onStart() to override default dismiss behaviour dialog.setPositiveButton(android.R.string.ok, null); dialog.setNegativeButton(android.R.string.cancel, null); final AlertDialog alertDialog = dialog.show(); mKeyTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { // noinspection unchecked SupportedKeyType keyType = ((Choice<SupportedKeyType>) parent.getSelectedItem()).getId(); // RadioGroup.getCheckedRadioButtonId() gives the wrong RadioButton checked // when programmatically unchecking children radio buttons. Clearing all is the only option. mUsageRadioGroup.clearCheck(); if (mWillBeMasterKey) { mUsageNone.setChecked(true); } if (keyType == SupportedKeyType.ECC_P521 || keyType == SupportedKeyType.ECC_P256) { mUsageSignAndEncrypt.setEnabled(false); if (mWillBeMasterKey) { mUsageEncrypt.setEnabled(false); } } else { // need to enable if previously disabled for ECC masterkey mUsageEncrypt.setEnabled(true); mUsageSignAndEncrypt.setEnabled(true); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); return alertDialog; }
From source file:com.example.drugsformarinemammals.Combined_Search.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.combined_search); helper = new Handler_Sqlite(this); userEntryAnatomicalTarget = ""; userEntryTherapeuticTarget = ""; userEntryAnimalTarget = ""; TextView title = (TextView) findViewById(R.id.CombinedSearch); title.setTypeface(Typeface.SANS_SERIF); Button go = (Button) findViewById(R.id.goButton); go.setTypeface(Typeface.SANS_SERIF); go.setOnClickListener(new OnClickListener() { @Override/*w ww . j a v a2s. c om*/ public void onClick(View v) { userEntryTherapeuticTarget = actv.getText().toString(); search(); } }); Spinner spinnerAnatomicalTarget = (Spinner) findViewById(R.id.SpinAnatomicalTarget); SpinnerAdapter adapterAnatomicalTarget = new SpinnerAdapter(this, R.layout.item_spinner, Arrays.asList(getResources().getStringArray(R.array.AnatomicalTarget))); adapterAnatomicalTarget.setDropDownViewResource(R.layout.spinner_dropdown_item); spinnerAnatomicalTarget.setAdapter(adapterAnatomicalTarget); spinnerAnatomicalTarget.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View arg1, int arg2, long arg3) { userEntryAnatomicalTarget = parent.getSelectedItem().toString(); } public void onNothingSelected(AdapterView<?> arg0) { } }); String[] urls = { "http://formmulary.tk/Android/getTherapeuticGroups.php" }; new GetTherapeuticGroups(this).execute(urls); Spinner spinnerAnimals = (Spinner) findViewById(R.id.SpinAnimals); SpinnerAdapter adapterAnimals = new SpinnerAdapter(this, R.layout.item_spinner, Arrays.asList(getResources().getStringArray(R.array.Animals))); adapterAnimals.setDropDownViewResource(R.layout.spinner_dropdown_item); spinnerAnimals.setAdapter(adapterAnimals); spinnerAnimals.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View arg1, int arg2, long arg3) { userEntryAnimalTarget = parent.getSelectedItem().toString(); } public void onNothingSelected(AdapterView<?> arg0) { } }); }