mardi 26 mai 2020

how to check float condition in if statement?

I change float value in string which is stored in Shared Preference. my float value by default is 0.0 but my if condition is not working..

Float savedX = SharedPref.getFloat(this,"Watermark_X");
String stringX = Float.toString(savedX);


if (stringX.equals(0.0)){
        Toast.makeText(this, "zero", Toast.LENGTH_SHORT).show();
        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) watermark.getLayoutParams();
        layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    }else {
        Toast.makeText(this, "filled", Toast.LENGTH_SHORT).show();
        watermark.setX(savedX);
        watermark.setY(savedY);
    }

i got same toast "filled" in all condition. please help...

........Sorry For My Bad English.......

Aucun commentaire:

Enregistrer un commentaire