我的萨尔曼·阿姆贾德我在我的应用程序中使用了两个微调器,并且在每个选择上都使用了 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);
}
}
}
}
}
}
}
}