How to create counter on button?

后端 未结 3 1068
你的背包
你的背包 2021-01-28 15:44

I want to create button with text = \"SomeText\" on center of this button and \"0\" on right part of button. Where \"0\" is the Counter and when I click this button Counter++ i

3条回答
  •  醉梦人生
    2021-01-28 16:24

    private static int counter = 0;
    
    button1.setOnClickListener(new OnClickListener(){
        @Override
        onClick(View v){
           counter += 1
           button.setText("Some text" + counter);
        }
     });
    

提交回复
热议问题