[Solved] Change Button Text on Button Click Infinite times [closed]


To accomplish what you want, globally declare an integer with a value 0. And inside onClick of button increment the value of integer and set that as text to button.

Sample Code:

Globally declare:

int count = 0;

Inside onCreate():

           button.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {

                  count++;
                  button.setText(""+count);

            }
        });

8

solved Change Button Text on Button Click Infinite times [closed]