jeudi 9 février 2017

Java script editing global variable

I wanted to check out something in Android Studio. I've never been doing in Java, so that's why I'm gonna ask.

I wanted to make a global variable to change it next using 2 buttons.

 Random number = new Random();
 int numb = number.nextInt(10-5) + 5;

Next I wanted to change this variable using each button - to generate other number when it's clicked.

if (numb %  2 == 0) {
        buttonClick1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String countValue = textCount.getText().toString();
                int counter = Integer.parseInt(countValue);
                counter++;
                textCount.setText(String.valueOf(counter));
                numb = 3;
            }
        });

How could I do it?

Sorry if the solution is clear ;)

Regards, Glox




Aucun commentaire:

Enregistrer un commentaire