Listener AutoCompleteTextView bug si vide
Bonjour a tous, j'ai un petit souci sur un autocomple, je vous explique j'ai fait un listener qui actualiser a chaque changement de texte voici le code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| //Changer a chaque changemenr de textr la bar de progres
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// AutoCompleteTextView AC_pression = (AutoCompleteTextView) findViewById(R.id.AC_pression);
int V_pression = 0;
final AutoCompleteTextView AC_pression = (AutoCompleteTextView) findViewById(R.id.AC_pression);
V_pression = Integer.parseInt(AC_pression.getText().toString());
//int litre = 6;
//double beu =1.1;
TextView TV_consomation = (TextView) findViewById(R.id.TV_consomation);
TV_consomation.setText("il lui reste "+ 6*V_pression*1 +"litre");
Log.d("Debug", String.valueOf(V_pression));
if (V_pression >=310) {
ProgressBar PB_pression = (ProgressBar) findViewById(R.id.circular_progress_bar);
ObjectAnimator anim = ObjectAnimator.ofInt(PB_pression, "progress", 0, 100);
anim.setDuration(1500);
anim.setInterpolator(new DecelerateInterpolator());
PB_pression.setProgress(100);
Drawable progressDrawable = getResources().getDrawable(R.drawable.circular_progressbar);
PB_pression.setProgressDrawable(progressDrawable);
anim.start();
} |
et cela dfonctione a merveille, seulement voila si j'entre des chiffre que que ensuite j'efface le dernier chiffre mon app plente et me met ce message ci:
Citation:
java.lang.NumberFormatException: Invalid int: ""
je comprends bien le problème mais je ne vois pas comment le contourné...
est ce que je doit définir un valeur par défaut?
Merci d'avance