Please suggest me how to set value in edit Text and Text view as a percentage format and currency format
if i enter in edit text 12345678.28 then it's give me currency as $12,345,678.28 and if i enter percentage as 10.25 it's give me 10.25%
Please suggest me how to set value in edit Text and Text view as a percentage format and currency format
if i enter in edit text 12345678.28 then it's give me currency as $12,345,678.28 and if i enter percentage as 10.25 it's give me 10.25%
you can achieve it by using TextWatcher or inputFilter
private String current = "";
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if(!s.toString().equals(current)){
[your_edittext].removeTextChangedListener(this);
String cleanString = s.toString().replaceAll("[$,.]", "");
double parsed = Double.parseDouble(cleanString);
String formated = NumberFormat.getCurrencyInstance().format((parsed/100));
current = formated;
[your_edittext].setText(formated);
[your_edittext].setSelection(formated.length());
[your_edittext].addTextChangedListener(this);
}
}
If you enter value in edit text append string like this..
Edittext et;
et.setonclickListener = new clicklistener()
{
et.settext("$" + "And get text from your edit text");
}