final EditText enter = (EditText) findViewById(R.id.enter);
final TextView result = (TextView) findViewById(R.id.result);
enter.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after)
{
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count)
{
}
@Override
public void afterTextChanged(Editable s)
{
if(enter.getText().length()!=0)
{
String ss= enter.gettext().toString();
ss= ss + "$";
enter.settext(ss);
}
else
{
result.setText(null);
}
}
});
enter.addTextChangedListener(new TextWatcher() {
private boolean mFormating;
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
if (!mFormating) {
mFormating = true;
if(enter.getText().length() != 0) {
String ss= s.toString();
if (!ss.endsWith("$")) {
ss= ss + "$";
enter.setText(ss);
}
} else {
result.setText(null);
}
mFormating = false;
}
}
});