I have the weirdest problem...
all I am trying to do is to get the value from a EditText and do some validation.
The value in the edittext must be between 1 and 10. However, even if I enter any number between 1 or 10 , it still validates false. I even tested the edittext input to make sure it is correct , and it is, but the if still fails . Any ideas ?
here is the code:
ed = (EditText) dialog2.findViewById(R.id.ed_quantity);
Button bq = (Button) dialog2.findViewById(R.id.alert_a);
dialog2.setCancelable(false);
dialog2.show();
bq.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v)
{
String test = ed.getText().toString();
Toast toast23452234 = Toast.makeText(mContext, "Quantity: "+test, Toast.LENGTH_LONG);
toast23452234.show();
if(test=="1"||test=="2"||test=="3"||test=="4"||test=="5"||test=="6"||test=="7"||test=="8"||test=="9"||test=="10")
{
quantity = Integer.parseInt(ed.getText().toString());
dialog2.dismiss();
ed.setText("1");
}
else
{
Toast toast2345223 = Toast.makeText(mContext, "Quantity must be between 1 and 10" , Toast.LENGTH_LONG);
toast2345223.show();
}
}
});