それは私のアプリで2つのスピナーを使用し、各選択でif else構造を使用している私です....しかし、アプリがロードされたときにデフォルトの選択条件が実行されます....デフォルトの選択を削除したいあなたは私を助けてくれますか???? また、最初の条件は最初に実行されません....
convertto.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View v1,
int index1, long arg3) {
//from meters
var1=Double.parseDouble(lvalue.getText().toString());
var2=var1;
if ((quantity[index1]=="Meter") && (s1.equalsIgnoreCase("Meter") ))
{
Toast.makeText(v1.getContext(), " to meter",Toast.LENGTH_SHORT).show();
var2=var1;
lresult.setText("" + var2);
}
else{
if ((quantity[index1]=="Inches") && (s1.equalsIgnoreCase("Meter")))
{
Toast.makeText(v1.getContext(), " to inches",Toast.LENGTH_SHORT).show();
var2=var1 * 39.3700787;
lresult.setText("" + var2);
}
else{
if ((quantity[index1]=="Feet") && (s1.equalsIgnoreCase("Meter")))
{
Toast.makeText(v1.getContext(), " to Feet",Toast.LENGTH_SHORT).show();
var2=var1 * 3.281;
lresult.setText("" + var2);
}
else{
if ((quantity[index1]=="Yards") && (s1.equalsIgnoreCase("Meter")))
{
Toast.makeText(v1.getContext(), " to Yards",Toast.LENGTH_SHORT).show();
var2=var1 * 1.0936133 ;
lresult.setText("" + var2);
}
}
}
//from inches
if ((quantity[index1]=="Meter") && (s1.equalsIgnoreCase("Inches")))
{
Toast.makeText(v1.getContext(), " to meter",Toast.LENGTH_SHORT).show();
var2=var1/39.3700787;
lresult.setText("" + var2);
}
else{
if ((quantity[index1]=="Inches") && (s1.equalsIgnoreCase("Inches")))
{
Toast.makeText(v1.getContext(), " to inches",Toast.LENGTH_SHORT).show();
var2=var1;
lresult.setText("" + var2);
}
else{
if ((quantity[index1]=="Feet") && (s1.equalsIgnoreCase("Inches")))
{
Toast.makeText(v1.getContext(), " to Feet",Toast.LENGTH_SHORT).show();
var2=var1/12;
lresult.setText("" + var2);
}
else{
if ((quantity[index1]=="Yards") && (s1.equalsIgnoreCase("Inches")))
{
Toast.makeText(v1.getContext(), " to Yards",Toast.LENGTH_SHORT).show();
var2 = var1/36;
lresult.setText("" + var2);
}
}
}
//from feet
if ((quantity[index1]=="Meter") && (s1.equalsIgnoreCase("Feet")))
{
Toast.makeText(v1.getContext(), " to meter",Toast.LENGTH_SHORT).show();
var2=var1/3.281;
lresult.setText("" + var2);
}
else{
if ((quantity[index1]=="Inches") && (s1.equalsIgnoreCase("Feet")))
{
Toast.makeText(v1.getContext(), " to inches",Toast.LENGTH_SHORT).show();
var2=var1*12;
lresult.setText("" + var2);
}
else{
if ((quantity[index1]=="Feet") && (s1.equalsIgnoreCase("Feet")))
{
Toast.makeText(v1.getContext(), " to Feet",Toast.LENGTH_SHORT).show();
var2=var1;
lresult.setText("" + var2);
}
else{
if ((quantity[index1]=="Yards") && (s1.equalsIgnoreCase("Feet")))
{
Toast.makeText(v1.getContext(), " to Yards",Toast.LENGTH_SHORT).show();
var2 = var1/3;
lresult.setText("" + var2);
}
}
}
//from yards
if ((quantity[index1]=="Meter") && (s1.equalsIgnoreCase("Yards")))
{
Toast.makeText(v1.getContext(), " to meter",Toast.LENGTH_SHORT).show();
var2=var1/1.0936133;
lresult.setText("" + var2);
}
else{
if ((quantity[index1]=="Inches") && (s1.equalsIgnoreCase("Yards")))
{
Toast.makeText(v1.getContext(), " to inches",Toast.LENGTH_SHORT).show();
var2=var1*36;
lresult.setText("" + var2);
}
else{
if ((quantity[index1]=="Feet") && (s1.equalsIgnoreCase("Yards")))
{
Toast.makeText(v1.getContext(), " to Feet",Toast.LENGTH_SHORT).show();
var2=var1*3;
lresult.setText("" + var2);
}
else{
if ((quantity[index1]=="Yards") && (s1.equalsIgnoreCase("Yards")))
{
Toast.makeText(v1.getContext(), " to Yards",Toast.LENGTH_SHORT).show();
var2 = var1;
lresult.setText("" + var2);
}
}
}
}
}
}
}
}