私の作品ですが、私が設定したをspinner
クリックする前に、ユーザーが選択したものを知りたいです。今のところ は本体でしか使えないのでどこでも使えるように を にconfirm button
設定するようなものかなと思っていspinners
ました。variable
どんな助けでも大歓迎です
public class Calculate extends Activity implements View.OnClickListener
{
int number = 0;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.setContentView(R.layout.calculate);
Spinner spinner1 = (Spinner) findViewById(R.id.hemsSpinner);
Spinner spinner2 = (Spinner) findViewById(R.id.materialSpinner);
Button butn1 = (Button) findViewById(R.id.calculateButton);
butn1.setOnClickListener(this);
// Selection of the spinner
// Application of the Array to the Spinner
ArrayAdapter<String> spinnerArrayAdapter1 = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,Hems.Hem);
spinnerArrayAdapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // The drop down view
spinner1.setAdapter(spinnerArrayAdapter1);
ArrayAdapter<String> spinnerArrayAdapter2 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,Material.Material);
spinnerArrayAdapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner2.setAdapter(spinnerArrayAdapter2);
EditText qty = (EditText)findViewById(R.id.qtyEditText);
double quantity = qty.getId();
EditText H = (EditText)findViewById(R.id.heightEditText);
double hight = H.getId();
EditText W = (EditText)findViewById(R.id.widthEditText);
double width = W.getId();
}
@Override
public void onClick(View v)
{
if(Calculate.spinner1.equals(Hems.Hem[0]))
{
number = 0;
}
else if (spinner1.equals(Hems.Hem[1]))
{
number = 1;
}
else if (spinner1.equals(Hems.Hem[2]))
{
number = 2;
}
else if (spinner1.equals(Hems.Hem[3]))
{
number = 3;
}
if (v.getId() == R.id.calculateButton)
{
TextView text = (TextView)findViewById(R.id.textView1);
text.setText(Hems.Hem[number]);
TextView dude = (TextView)findViewById(R.id.textView2);
dude.setText((int) Hems.hemPrice[number]);
}
}
}