Answer the question
In order to leave comments, you need to log in
How to manage variables with android buttons?
I have an application where there are many buttons on one activity, I need a variable to be saved after clicking on each, that is, I have 4 rows horizontally and each row has 9 buttons (from 1 to 9) for each button via cwich a variable is set example:
switch (v.getId()) {
case R.id.ps0: a = 0;
break;
case R.id.ps1: a = 1;
break;
case R.id.ps2: a = 2; //и так до 9
case R.id.vs0: b = 0;
break;
case R.id.vs1: b = 1;
break;
case R.id.vs2: b = 2;
break;
case R.id.vs3: b = 3;
break;
case R.id.vs4: b = 4; // и соответственно третий ряд
break;
case R.id.ts0: c = 0;
break;
case R.id.ts1: c = 1;
break;
case R.id.ts2: c = 2; //так соответственно тоже 9 кнопок
break;
result = (a*100+b*10+c*1)/100
textView.setText(result);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question