I am making an application that takes the data entered in a EditText
and does a certain calculation.
The problem is that I need the field to go from 1 to 100%, but the mask I'm using is too simple for this, so it only makes the limitation but goes from 0 to 999 and it's not that that I want.
I also can not put the% symbol at the end of this field.
Follow the code:
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.EditText;
import com.github.rtoshiro.util.format.MaskFormatter;
import com.github.rtoshiro.util.format.SimpleMaskFormatter;
import com.github.rtoshiro.util.format.pattern.MaskPattern;
import com.github.rtoshiro.util.format.text.MaskTextWatcher;
public class ActivityForm extends AppCompatActivity {
private EditText percentual;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_activity_form);
percentual = (EditText) findViewById(R.id.percentual_Id);
SimpleMaskFormatter simpleMaskPercentual = new SimpleMaskFormatter( " NNN% " );
MaskTextWatcher maskPercentual = new MaskTextWatcher(percentual, simpleMaskPercentual);
percentual.addTextChangedListener( maskPercentual );
}
}