List of usage examples for android.widget AdapterView getSelectedItem
public Object getSelectedItem()
From source file:org.sufficientlysecure.keychain.ui.dialog.CreateKeyDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final FragmentActivity context = getActivity(); final LayoutInflater mInflater; final int childCount = getArguments().getInt(ARG_EDITOR_CHILD_COUNT); mInflater = context.getLayoutInflater(); CustomAlertDialogBuilder dialog = new CustomAlertDialogBuilder(context); View view = mInflater.inflate(R.layout.create_key_dialog, null); dialog.setView(view);/*ww w . ja v a 2 s.com*/ dialog.setTitle(R.string.title_create_key); boolean wouldBeMasterKey = (childCount == 0); mAlgorithmSpinner = (Spinner) view.findViewById(R.id.create_key_algorithm); ArrayList<Choice> choices = new ArrayList<Choice>(); choices.add(new Choice(Constants.choice.algorithm.dsa, getResources().getString(R.string.dsa))); if (!wouldBeMasterKey) { choices.add(new Choice(Constants.choice.algorithm.elgamal, getResources().getString(R.string.elgamal))); } choices.add(new Choice(Constants.choice.algorithm.rsa, getResources().getString(R.string.rsa))); ArrayAdapter<Choice> adapter = new ArrayAdapter<Choice>(context, android.R.layout.simple_spinner_item, choices); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mAlgorithmSpinner.setAdapter(adapter); // make RSA the default for (int i = 0; i < choices.size(); ++i) { if (choices.get(i).getId() == Constants.choice.algorithm.rsa) { mAlgorithmSpinner.setSelection(i); break; } } mKeySizeSpinner = (Spinner) view.findViewById(R.id.create_key_size); // dynamic ArrayAdapter must be created (instead of ArrayAdapter.getFromResource), because it's content may change ArrayAdapter<CharSequence> keySizeAdapter = new ArrayAdapter<CharSequence>(context, android.R.layout.simple_spinner_item, new ArrayList<CharSequence>( Arrays.asList(getResources().getStringArray(R.array.rsa_key_size_spinner_values)))); keySizeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mKeySizeSpinner.setAdapter(keySizeAdapter); mKeySizeSpinner.setSelection(1); // Default to 4096 for the key length mCustomKeyTextView = (TextView) view.findViewById(R.id.custom_key_size_label); mCustomKeyEditText = (EditText) view.findViewById(R.id.custom_key_size_input); mCustomKeyInfoTextView = (TextView) view.findViewById(R.id.custom_key_size_info); dialog.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface di, int id) { di.dismiss(); mNewKeyAlgorithmChoice = (Choice) mAlgorithmSpinner.getSelectedItem(); mNewKeySize = getProperKeyLength(mNewKeyAlgorithmChoice.getId(), getSelectedKeyLength()); mAlgorithmSelectedListener.onAlgorithmSelected(mNewKeyAlgorithmChoice, mNewKeySize); } }); dialog.setCancelable(true); dialog.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface di, int id) { di.dismiss(); } }); final AlertDialog alertDialog = dialog.show(); mCustomKeyEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { setOkButtonAvailability(alertDialog); } }); mKeySizeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { setCustomKeyVisibility(); setOkButtonAvailability(alertDialog); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); mAlgorithmSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { setKeyLengthSpinnerValuesForAlgorithm(((Choice) parent.getSelectedItem()).getId()); setCustomKeyVisibility(); setOkButtonAvailability(alertDialog); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); return alertDialog; }
From source file:com.example.drugsformarinemammals.General_Info_Drug.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.general_info_drug); isStoredInLocal = false;/*w w w. j a v a2s.c o m*/ fiveLastScreen = false; helper = new Handler_Sqlite(this); helper.open(); Bundle extras1 = this.getIntent().getExtras(); if (extras1 != null) { infoBundle = extras1.getStringArrayList("generalInfoDrug"); fiveLastScreen = extras1.getBoolean("fiveLastScreen"); if (infoBundle == null) isStoredInLocal = true; if (!isStoredInLocal) { initializeGeneralInfoDrug(); initializeCodesInformation(); initializeCodes(); } else { drug_name = extras1.getString("drugName"); codes = helper.getCodes(drug_name); codesInformation = helper.getCodesInformation(drug_name); } //Title TextView drugTitle = (TextView) findViewById(R.id.drugTitle); drugTitle.setText(drug_name); drugTitle.setTypeface(Typeface.SANS_SERIF); //Description LinearLayout borderDescription = new LinearLayout(this); borderDescription.setOrientation(LinearLayout.VERTICAL); borderDescription .setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); borderDescription.setBackgroundResource(R.drawable.layout_border); TextView description = new TextView(this); if (isStoredInLocal) description.setText(helper.getDescription(drug_name)); else description.setText(this.description); description.setTextSize(18); description.setTypeface(Typeface.SANS_SERIF); LinearLayout.LayoutParams paramsDescription = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); paramsDescription.leftMargin = 60; paramsDescription.rightMargin = 60; paramsDescription.topMargin = 20; borderDescription.addView(description, borderDescription.getChildCount(), paramsDescription); LinearLayout layoutDescription = (LinearLayout) findViewById(R.id.layoutDescription); layoutDescription.addView(borderDescription, layoutDescription.getChildCount()); //Animals TextView headerAnimals = (TextView) findViewById(R.id.headerAnimals); headerAnimals.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); Button cetaceansButton = (Button) findViewById(R.id.cetaceansButton); cetaceansButton.setText("CETACEANS"); cetaceansButton.setTypeface(Typeface.SANS_SERIF); cetaceansButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showDoseInformation(drug_name, "Cetaceans"); } }); Button pinnipedsButton = (Button) findViewById(R.id.pinnipedsButton); pinnipedsButton.setText("PINNIPEDS"); pinnipedsButton.setTypeface(Typeface.SANS_SERIF); pinnipedsButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { SQLiteDatabase db = helper.open(); ArrayList<String> families = new ArrayList<String>(); if (db != null) families = helper.read_animals_family(drug_name, "Pinnipeds"); if ((families != null && families.size() == 1 && families.get(0).equals("")) || (families != null && families.size() == 0)) showDoseInformation(drug_name, "Pinnipeds"); else showDoseInformationPinnipeds(drug_name, families); } }); Button otherButton = (Button) findViewById(R.id.otherButton); otherButton.setText("OTHER MM"); otherButton.setTypeface(Typeface.SANS_SERIF); otherButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showDoseInformation(drug_name, "Other MM"); } }); //Codes & therapeutic target & anatomical target TextView headerATCvetCodes = (TextView) findViewById(R.id.headerATCvetCodes); headerATCvetCodes.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); //Action TextView headerActionAnatomical = (TextView) findViewById(R.id.headerActionAnatomical); headerActionAnatomical.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); createTextViewAnatomical(); createBorderAnatomicalGroup(); TextView headerActionTherapeutic = (TextView) findViewById(R.id.headerActionTherapeutic); headerActionTherapeutic.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); createTextViewTherapeutic(); createBorderTherapeuticGroup(); params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.leftMargin = 60; params.rightMargin = 60; params.topMargin = 20; Spinner codesSpinner = (Spinner) findViewById(R.id.codesSpinner); SpinnerAdapter adapterCodes = new SpinnerAdapter(this, R.layout.item_spinner, codes); adapterCodes.setDropDownViewResource(R.layout.spinner_dropdown_item); codesSpinner.setAdapter(adapterCodes); codesSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View arg1, int arg2, long arg3) { userEntryCode = parent.getSelectedItem().toString(); int numCodes = codesInformation.size(); layoutAnatomicalGroup.removeView(borderAnatomicalGroup); createBorderAnatomicalGroup(); boolean founded = false; int i = 0; while (!founded && i < numCodes) { if (userEntryCode.equals(codesInformation.get(i).getCode())) { createTextViewAnatomical(); anatomicalGroup.setText(codesInformation.get(i).getAnatomic_group() + "\n"); borderAnatomicalGroup.addView(anatomicalGroup, borderAnatomicalGroup.getChildCount(), params); founded = true; } i++; } layoutAnatomicalGroup = (LinearLayout) findViewById(R.id.layoutActionAnatomical); layoutAnatomicalGroup.addView(borderAnatomicalGroup, layoutAnatomicalGroup.getChildCount()); layoutTherapeuticGroup.removeView(borderTherapeuticGroup); createBorderTherapeuticGroup(); founded = false; i = 0; while (!founded && i < numCodes) { if (userEntryCode.equals(codesInformation.get(i).getCode())) { createTextViewTherapeutic(); therapeuticGroup.setText(codesInformation.get(i).getTherapeutic_group() + "\n"); borderTherapeuticGroup.addView(therapeuticGroup, borderTherapeuticGroup.getChildCount(), params); founded = true; } i++; } layoutTherapeuticGroup = (LinearLayout) findViewById(R.id.layoutActionTherapeutic); layoutTherapeuticGroup.addView(borderTherapeuticGroup, layoutTherapeuticGroup.getChildCount()); } public void onNothingSelected(AdapterView<?> arg0) { } }); layoutAnatomicalGroup = (LinearLayout) findViewById(R.id.layoutActionAnatomical); layoutTherapeuticGroup = (LinearLayout) findViewById(R.id.layoutActionTherapeutic); borderTherapeuticGroup.addView(therapeuticGroup, borderTherapeuticGroup.getChildCount(), params); borderAnatomicalGroup.addView(anatomicalGroup, borderAnatomicalGroup.getChildCount(), params); layoutAnatomicalGroup.addView(borderAnatomicalGroup, layoutAnatomicalGroup.getChildCount()); layoutTherapeuticGroup.addView(borderTherapeuticGroup, layoutTherapeuticGroup.getChildCount()); //Generic Drug TextView headerGenericDrug = (TextView) findViewById(R.id.headerGenericDrug); headerGenericDrug.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); boolean isAvalaible = false; if (isStoredInLocal) isAvalaible = helper.isAvalaible(drug_name); else isAvalaible = available.equals("Yes"); if (isAvalaible) { ImageView genericDrug = new ImageView(this); genericDrug.setImageResource(R.drawable.tick_verde); LinearLayout layoutGenericDrug = (LinearLayout) findViewById(R.id.layoutGenericDrug); layoutGenericDrug.addView(genericDrug); } else { Typeface font = Typeface.createFromAsset(getAssets(), "Typoster_demo.otf"); TextView genericDrug = new TextView(this); genericDrug.setTypeface(font); genericDrug.setText("Nd"); genericDrug.setTextColor(getResources().getColor(R.color.maroon)); genericDrug.setTextSize(20); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int size = metrics.widthPixels; int middle = size / 2; int quarter = size / 4; genericDrug.setTranslationX(middle - quarter); genericDrug.setTranslationY(-3); LinearLayout layoutGenericDrug = (LinearLayout) findViewById(R.id.layoutGenericDrug); layoutGenericDrug.addView(genericDrug); } //Licenses TextView headerLicense = (TextView) findViewById(R.id.headerLicense); headerLicense.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); TextView fdaLicense = (TextView) findViewById(R.id.license1); Typeface font = Typeface.createFromAsset(getAssets(), "Typoster_demo.otf"); fdaLicense.setTypeface(font); String fda; if (isStoredInLocal) fda = helper.getLicense_FDA(drug_name); else fda = license_FDA; if (fda.equals("Yes")) { fdaLicense.setText("Yes"); fdaLicense.setTextColor(getResources().getColor(R.color.lightGreen)); } else { fdaLicense.setText("Nd"); fdaLicense.setTextColor(getResources().getColor(R.color.maroon)); } TextView emaLicense = (TextView) findViewById(R.id.license3); emaLicense.setTypeface(font); String ema; if (isStoredInLocal) ema = helper.getLicense_EMA(drug_name); else ema = license_EMA; if (ema.equals("Yes")) { emaLicense.setText("Yes"); emaLicense.setTextColor(getResources().getColor(R.color.lightGreen)); } else { emaLicense.setText("Nd"); emaLicense.setTextColor(getResources().getColor(R.color.maroon)); } TextView aempsLicense = (TextView) findViewById(R.id.license2); aempsLicense.setTypeface(font); String aemps; if (isStoredInLocal) aemps = helper.getLicense_AEMPS(drug_name); else aemps = license_AEMPS; if (aemps.equals("Yes")) { aempsLicense.setText("Yes"); aempsLicense.setTextColor(getResources().getColor(R.color.lightGreen)); } else { aempsLicense.setText("Nd"); aempsLicense.setTextColor(getResources().getColor(R.color.maroon)); } ImageButton food_and_drug = (ImageButton) findViewById(R.id.food_and_drug); food_and_drug.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse( "http://www.fda.gov/animalveterinary/products/approvedanimaldrugproducts/default.htm")); startActivity(intent); } }); ImageButton european_medicines_agency = (ImageButton) findViewById(R.id.european_medicines_agency); european_medicines_agency.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse( "http://www.ema.europa.eu/ema/index.jsp?curl=pages/medicines/landing/vet_epar_search.jsp&mid=WC0b01ac058001fa1c")); startActivity(intent); } }); ImageButton logo_aemps = (ImageButton) findViewById(R.id.logo_aemps); logo_aemps.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse( "http://www.aemps.gob.es/medicamentosVeterinarios/Med-Vet-autorizados/home.htm")); startActivity(intent); } }); if (helper.existDrug(drug_name)) { int drug_priority = helper.getDrugPriority(drug_name); ArrayList<String> sorted_drugs = new ArrayList<String>(); sorted_drugs.add(0, drug_name); for (int i = 1; i < drug_priority; i++) { String name = helper.getDrugName(i); sorted_drugs.add(i, name); } for (int i = 0; i < sorted_drugs.size(); i++) helper.setDrugPriority(sorted_drugs.get(i), i + 1); } if (!isStoredInLocal) { //Server code String[] urls = { "http://formmulary.tk/Android/getDoseInformation.php?drug_name=", "http://formmulary.tk/Android/getGeneralNotesInformation.php?drug_name=" }; new GetDoseInformation(this).execute(urls); } helper.close(); } }
From source file:com.df.dfcarchecker.CarCheck.CarCheckBasicInfoFragment.java
private void setSpinnerSelection(final int spinnerId, int selection) { final Spinner spinner = (Spinner) rootView.findViewById(spinnerId); spinner.setSelection(selection);// w w w .j a v a 2 s.co m spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { CarCheckIntegratedFragment.updateAssociatedSpinners(spinnerId, adapterView.getSelectedItem().toString()); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); }
From source file:org.de.jmg.learn.SettingsActivity.java
private void initSpinners(boolean blnRestart) { libLearn.gStatus = "initSpinners"; try {/*from www . j av a 2 s . c om*/ spnAbfragebereich = (Spinner) findViewById(R.id.spnAbfragebereich); spnASCII = (Spinner) findViewById(R.id.spnASCII); spnStep = (Spinner) findViewById(R.id.spnStep); spnDisplayDurationWord = (Spinner) findViewById(R.id.spnAnzeigedauerWord); spnDisplayDurationBed = (Spinner) findViewById(R.id.spnAnzeigedauerBed); spnPaukRepetitions = (Spinner) findViewById(R.id.spnRepetitions); spnProbabilityFactor = (Spinner) findViewById(R.id.spnProbabilityFactor); spnRestartInterval = (Spinner) findViewById(R.id.spnRestartInterval); spnLanguages = (Spinner) findViewById(R.id.spnLanguages); spnColors = (org.de.jmg.lib.NoClickSpinner) findViewById(R.id.spnColors); spnSounds = (org.de.jmg.lib.NoClickSpinner) findViewById(R.id.spnSounds); spnLangWord = (Spinner) findViewById(R.id.spnLangWord); spnLangMeaning = (Spinner) findViewById(R.id.spnLangMeaning); if (!blnRestart) langinitialized = 0; else langinitialized = 0; if (spnAbfragebereich.getAdapter() != null && spnAbfragebereich.getAdapter().getCount() > 0) return; if (Colors == null || Colors != null) { Colors = new ColorsArrayAdapter(_main, R.layout.spinnerrow); Colors.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); Sounds = new SoundsArrayAdapter(_main, R.layout.soundsspinnerrow); Sounds.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); } spnASCII.getBackground().setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_ATOP); spnStep.getBackground().setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_ATOP); spnDisplayDurationBed.getBackground().setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_ATOP); spnDisplayDurationWord.getBackground().setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_ATOP); spnAbfragebereich.getBackground().setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_ATOP); spnPaukRepetitions.getBackground().setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_ATOP); spnProbabilityFactor.getBackground().setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_ATOP); spnRestartInterval.getBackground().setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_ATOP); spnLanguages.getBackground().setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_ATOP); //spnColors.getBackground().setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_ATOP); //spnSounds.getBackground().setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_ATOP); // Create an ArrayAdapter using the string array and a default // spinner layout ScaledArrayAdapter<CharSequence> adapter = ScaledArrayAdapter.createFromResource(_main, R.array.spnAbfragebereichEntries, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices appears adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); if (lib.NookSimpleTouch() && mScale == 1) adapter.Scale = 1.8f; // Apply the adapter to the spinner spnAbfragebereich.setAdapter(adapter); spnAbfragebereich.setSelection(getIntent().getShortExtra("Abfragebereich", (short) -1) + 1); spnAbfragebereich.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { intent.putExtra("Abfragebereich", (short) (position - 1)); intent.putExtra("OK", "OK"); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); ScaledArrayAdapter<CharSequence> adapterStep = ScaledArrayAdapter.createFromResource(_main, R.array.spnStepEntries, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices appears adapterStep.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Apply the adapter to the spinner if (lib.NookSimpleTouch() && mScale == 1) adapterStep.Scale = 1.8f; spnStep.setAdapter(adapterStep); spnStep.setSelection(adapterStep.getPosition("" + getIntent().getShortExtra("Step", (short) 5))); spnStep.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { intent.putExtra("Step", (short) (Integer.parseInt((String) parent.getItemAtPosition(position)))); intent.putExtra("OK", "OK"); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); ScaledArrayAdapter<String> adapterASCII = new ScaledArrayAdapter<String>(_main, android.R.layout.simple_spinner_item); // adapterASCII.addAll(Charset.availableCharsets().values()); ArrayList<String> charsets = new ArrayList<String>(); for (Charset c : Charset.availableCharsets().values()) { charsets.add(c.name()); } adapterASCII.addAll(charsets); // Specify the layout to use when the list of choices appears adapterASCII.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Apply the adapter to the spinner if (lib.NookSimpleTouch() && mScale == 1) adapterASCII.Scale = 1.8f; spnASCII.setAdapter(adapterASCII); String CharsetASCII = getIntent().getStringExtra("CharsetASCII"); if (!libString.IsNullOrEmpty(CharsetASCII)) { int i = 0; for (Charset c : Charset.availableCharsets().values()) { if (c.name().equalsIgnoreCase(CharsetASCII)) { break; } i++; } if (i < adapterASCII.getCount()) { spnASCII.setSelection(i); } } spnASCII.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { intent.putExtra("CharsetASCII", ((String) (parent.getSelectedItem()))); intent.putExtra("OK", "OK"); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); final ScaledArrayAdapter<CharSequence> adapterDDWord = ScaledArrayAdapter.createFromResource(_main, R.array.spnDurations, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices appears adapterDDWord.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); if (lib.NookSimpleTouch() && mScale == 1) adapterDDWord.Scale = 1.8f; // Apply the adapter to the spinner spnDisplayDurationWord.setAdapter(adapterDDWord); String strDD = "" + getIntent().getFloatExtra("DisplayDurationWord", 1.5f); strDD = strDD.replace(".0", ""); int Pos = adapterDDWord.getPosition(strDD); spnDisplayDurationWord.setSelection(Pos); spnDisplayDurationWord.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { intent.putExtra("DisplayDurationWord", (Float.parseFloat((String) parent.getItemAtPosition(position)))); intent.putExtra("OK", "OK"); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); ScaledArrayAdapter<CharSequence> adapterDDBed = ScaledArrayAdapter.createFromResource(_main, R.array.spnDurations, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices appears adapterDDBed.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); if (lib.NookSimpleTouch() && mScale == 1) adapterDDBed.Scale = 1.8f; // Apply the adapter to the spinner spnDisplayDurationBed.setAdapter(adapterDDBed); strDD = "" + getIntent().getFloatExtra("DisplayDurationBed", 2.5f); strDD = strDD.replace(".0", ""); Pos = adapterDDBed.getPosition(strDD); spnDisplayDurationBed.setSelection(Pos); spnDisplayDurationBed.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { intent.putExtra("DisplayDurationBed", (Float.parseFloat((String) parent.getItemAtPosition(position)))); intent.putExtra("OK", "OK"); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); ScaledArrayAdapter<CharSequence> adapterPaukRepetitions = ScaledArrayAdapter.createFromResource(_main, R.array.spnRepetitions, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices appears adapterPaukRepetitions.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); if (lib.NookSimpleTouch() && mScale == 1) adapterPaukRepetitions.Scale = 1.8f; spnPaukRepetitions.setAdapter(adapterPaukRepetitions); Pos = getIntent().getIntExtra("PaukRepetitions", 3) - 1; spnPaukRepetitions.setSelection(Pos); spnPaukRepetitions.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { intent.putExtra("PaukRepetitions", (Integer.parseInt((String) parent.getItemAtPosition(position)))); intent.putExtra("OK", "OK"); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); ScaledArrayAdapter<CharSequence> adapterProbabilityFactor = ScaledArrayAdapter.createFromResource(_main, R.array.spnProbabilityFactors, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices appears adapterProbabilityFactor.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); if (lib.NookSimpleTouch() && mScale == 1) adapterProbabilityFactor.Scale = 1.8f; spnProbabilityFactor.setAdapter(adapterProbabilityFactor); float ProbabilityFactor = getIntent().getFloatExtra("ProbabilityFactor", -1f); if (ProbabilityFactor == -1) { strDD = _main.getString((R.string.auto)); } else { strDD = "" + ProbabilityFactor; strDD = strDD.replace(".0", ""); } ArrayAdapter<CharSequence> a1 = adapterProbabilityFactor; if (a1 != null) { try { libLearn.gStatus = "get Spinneradapter ProbabilityFactor"; Pos = (a1.getPosition(strDD)); spnProbabilityFactor.setSelection(Pos); } catch (Exception ex) { lib.ShowException(_main, ex); } } spnProbabilityFactor.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { String strDD = (String) parent.getItemAtPosition(position); if (strDD.equalsIgnoreCase(_main.getString(R.string.auto))) strDD = "-1"; intent.putExtra("ProbabilityFactor", (Float.parseFloat(strDD))); intent.putExtra("OK", "OK"); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); ScaledArrayAdapter<CharSequence> adapterRestartInterval = ScaledArrayAdapter.createFromResource(_main, R.array.spnRestartInterval, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices appears adapterRestartInterval.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); if (lib.NookSimpleTouch() && mScale == 1) adapterRestartInterval.Scale = 1.8f; spnRestartInterval.setAdapter(adapterRestartInterval); int RestartInterval = getIntent().getIntExtra("RestartInterval", -1); if (RestartInterval == -1) { strDD = _main.getString(R.string.off); } else { strDD = "" + RestartInterval; } a1 = adapterRestartInterval; if (a1 != null) { try { libLearn.gStatus = "get Spinneradapter ProbabilityFactor"; Pos = (a1.getPosition(strDD)); spnRestartInterval.setSelection(Pos); } catch (Exception ex) { lib.ShowException(_main, ex); } } spnRestartInterval.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { String strDD = (String) parent.getItemAtPosition(position); if (strDD.equalsIgnoreCase(_main.getString(R.string.off))) strDD = "-1"; intent.putExtra("RestartInterval", (Integer.parseInt(strDD))); intent.putExtra("OK", "OK"); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); ScaledArrayAdapter<CharSequence> adapterLanguages = ScaledArrayAdapter.createFromResource(_main, R.array.spnLanguages, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices appears adapterLanguages.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); if (lib.NookSimpleTouch() && mScale == 1) adapterLanguages.Scale = 1.8f; spnLanguages.setAdapter(adapterLanguages); int Language = getIntent().getIntExtra("Language", org.de.jmg.learn.vok.Vokabel.EnumSprachen.undefiniert.ordinal()); spnLanguages.setSelection(Language); spnLanguages.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { intent.putExtra("Language", position); intent.putExtra("OK", "OK"); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); adapterLangWord = new ScaledArrayAdapter<>(_main, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices appears adapterLangWord.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); if (lib.NookSimpleTouch() && mScale == 1) adapterLangWord.Scale = 1.8f; adapterLangWord.add(new DisplayLocale(new Locale("", ""))); adapterLangWord.add(new DisplayLocale(new Locale("_off"))); for (Locale l : Locale.getAvailableLocales()) { DisplayLocale dl = new DisplayLocale(l); adapterLangWord.add(dl); } sortLangWord(); spnLangWord.setAdapter(adapterLangWord); /* if (selectedLocale != null) { int pos = adapterLangWord.getPosition(selectedLocale); spnLangWord.setSelection (-1); spnLangWord.setSelection(pos); }*/ spnLangWord.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (position <= 0 || langinitialized == 0) { langinitialized += 1; return; } Locale l = adapterLangWord.getItem(position).locale; int res = 0; if (_main.tts.isLanguageAvailable(Locale.US) >= 0) { res = _main.tts.setLanguage(l); } if (!chkTextToSpeech.isChecked() || res >= 0 || l.toString().equalsIgnoreCase("_off") || !_main.blnTextToSpeech || lib.ShowMessageYesNo(_main, String.format(_main.getString(R.string.msgLanguageNotavailable), l.getDisplayLanguage() + " " + l.getDisplayCountry()), "") == yesnoundefined.yes) { intent.putExtra("langword", lib.toLanguageTag(l)); intent.putExtra("OK", "OK"); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); adapterLangMeaning = new ScaledArrayAdapter<>(_main, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices appears adapterLangMeaning.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); if (lib.NookSimpleTouch() && mScale == 1) adapterLangMeaning.Scale = 1.8f; adapterLangMeaning.add(new DisplayLocale(new Locale("", ""))); adapterLangMeaning.add(new DisplayLocale(new Locale("_off"))); for (Locale l : Locale.getAvailableLocales()) { DisplayLocale dl = new DisplayLocale((l)); adapterLangMeaning.add(dl); } sortLangMeaning(); spnLangMeaning.setAdapter(adapterLangMeaning); /* if (selectedLocale != null) { int pos = adapterLangMeaning.getPosition(selectedLocale); spnLangMeaning.setSelection(-1); spnLangMeaning.setSelection(pos); } */ spnLangMeaning.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (position <= 0 || langinitialized < 2) { langinitialized += 1; return; } Locale l = adapterLangMeaning.getItem(position).locale; int res = 0; if (_main.tts.isLanguageAvailable(Locale.US) >= 0) { res = _main.tts.setLanguage(l); } if (!chkTextToSpeech.isChecked() || res >= 0 || l.toString().equalsIgnoreCase("_off") || !_main.blnTextToSpeech || lib.ShowMessageYesNo(_main, String.format(_main.getString(R.string.msgLanguageNotavailable), l.getDisplayLanguage() + " " + l.getDisplayCountry()), "") == yesnoundefined.yes) { intent.putExtra("langmeaning", lib.toLanguageTag(l)); intent.putExtra("OK", "OK"); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); if (lib.NookSimpleTouch() && mScale == 1) Colors.Scale = 1.8f; spnColors.setAdapter(Colors); spnColors.setOnLongClickListener(new android.widget.AdapterView.OnLongClickListener() { @Override public boolean onLongClick(View v) { spnColors.blnDontCallOnClick = true; ShowColorDialog(); return false; } }); spnColors.setOnItemLongClickListener(new android.widget.AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { spnColors.blnDontCallOnClick = true; ShowColorDialog(); return false; } }); if (lib.NookSimpleTouch() && mScale == 1) Sounds.Scale = 1.8f; spnSounds.setAdapter(Sounds); spnSounds.setOnLongClickListener(new android.widget.AdapterView.OnLongClickListener() { @Override public boolean onLongClick(View v) { spnSounds.blnDontCallOnClick = true; ShowSoundsDialog(); return false; } }); spnSounds.setOnItemLongClickListener(new android.widget.AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { spnSounds.blnDontCallOnClick = true; ShowSoundsDialog(); return false; } }); spnSounds.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { SoundSetting item = (SoundSetting) parent.getItemAtPosition(position); File F = new File(item.SoundPath); try { if (F.exists()) lib.playSound(F); else lib.playSound(_main.getAssets(), item.SoundPath); } catch (Exception e) { e.printStackTrace(); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); } catch (Exception ex) { lib.ShowException(_main, ex); } }