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 ...
...anddeletethelastcharacter,thatis,whenIdeletethelastremainingnumber(inthiscasethe"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 it has nothing entered by the user, 0 appears in EditText and also if it has something, and then everything is deleted, it resumes , so even if the user tries to delete that number 0 it stays strong and strong. p>
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) {
}
});
}
}