2
I type a number sequence normally and Talz, now if for example I type "1234" in any of the 3 Edittexts existing in my Activity...
... and delete until the last character, ie when I delete the last remaining number (in case the "1"), the app for:
I would like the problem to be solved in order to make the number 0 a mandatory character, that is, if you have nothing entered by the user, number 0 appears in Edittext and also if you have something, and then it’s all erased, he reappears, so that even if the user tries to delete that number 0 he stands firm and strong.
Main01activity:
package genesysgeneration.ruleoftree;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class Main01Activity extends AppCompatActivity {
private EditText et01, et02, et03;
private TextView tv01;
private long l01, l02, l03;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main01);
l01=0;
l02=0;
l03=0;
tv01=(TextView)findViewById(R.id.tv01);
et01=(EditText)findViewById(R.id.et01);
et02=(EditText)findViewById(R.id.et02);
et03=(EditText)findViewById(R.id.et03);
addValuesLong();
}
private void addValuesLong(){
et01.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) {
l01=Long.parseLong(et01.getText().toString().trim());
tv01.setText(String.valueOf(l01*l02*l03));
}
@Override
public void afterTextChanged(Editable s) {
}
});
et02.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) {
l02=Long.parseLong(et02.getText().toString().trim());
tv01.setText(String.valueOf(l01*l02*l03));
}
@Override
public void afterTextChanged(Editable s) {
}
});
et03.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) {
l03=Long.parseLong(et03.getText().toString().trim());
tv01.setText(String.valueOf(l01*l02*l03));
}
@Override
public void afterTextChanged(Editable s) {
}
});
}
}
of your code?
– viana