There are 2 edittext, 2 spinner and a button with a textview. This is the idea. Enter 2 values into edittext on one spinner, select a valid brand, and in the second, the size and everything counted when the button is pressed ....
dlina = (EditText)findViewById(R.id.dlina); shirina = (EditText)findViewById(R.id.shirina); tip = (Spinner)findViewById(R.id.tip); razmer = (Spinner) findViewById(R.id.razmer); rasschet = (Button)findViewById(R.id.rasschet); otvet = (TextView)findViewById(R.id.otvet); tip.setOnItemSelectedListener(this); rasschet.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (!TextUtils.isEmpty(dlina.getText().toString())) { a = Integer.parseInt(dlina.getText().toString()); } else { a = 0; if (dlina.getText().toString().length() == 0) dlina.setError(getString(R.string.dlina)); } if (!TextUtils.isEmpty(shirina.getText().toString())) { b = Integer.parseInt(shirina.getText().toString()); } else { b = 0; if (shirina.getText().toString().length() == 0) shirina.setError(getString(R.string.shirina)); } d = a * b * c; otvet.setText(Integer.toString(d)); } }); @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { String tips = String.valueOf(tip.getSelectedItem()); pos = tip.getSelectedItemPosition(); if (pos == 0) { c = 2; } if (pos == 1) { c = 4; } if (pos == 2) { c = 6; } //Toast.makeText(this, tips, Toast.LENGTH_SHORT).show(); if (tips.contentEquals("ballon")) { List<String> list = new ArrayList<String>(); list.add("120,7 × 19,3"); list.add("128,8 × 18,6"); ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, list); dataAdapter.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item); dataAdapter.notifyDataSetChanged(); razmer.setAdapter(dataAdapter); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } With this code, when I press the button, I get an answer because the letter C in the formula is crammed under the first spinner, and I need the letter C in the formula to react to the second spinner into which I am dimensioning .... Help the citizens, atoms have already broken their head ... Thanks in advance
spinner.setOnItemSelectedListener(new OnItemSelectedListener(){...});- YurySPb ♦Cfrom the handler of the first spinner? You need to act this way: in the first spinner, on the position, create data for the second spinner, fill its adapter and assign it to the listener, in which you must work withC.. - Yuri SPb ♦