Q:

i want to create a counter with a text view

i want to create a counter with a text view and want for every 15 click , to change the text in the text view and that is what i have wrote to create the counter ........ i have two text views .... one for the no. of clicks and the another for the text i want to show ,,,,,,,,,,, so i want to use "if" to set the counter to 0 (the counter is tvx) and to change the text (tvx2) to "click 15 more"
@Override
protected void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tips_2);

    btn = (Button) findViewById(R.id.bt);
    txv = (TextView) findViewById(R.id.tx);
    txv2 = (TextView) findViewById(R.id.tx2);

    btn.setOnClickListener(new View.OnClickListener() 
    {
        public int mCounter;
        public Integer tx;

        @Override
        public void onClick(View v) {
            mCounter++;
            txv.setText(Integer.toString(mCounter));
        }
    });
}

A:

    @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tips_2);

    btn = (Button) findViewById(R.id.bt);
    txv = (TextView) findViewById(R.id.tx);
    txv2 = (TextView) findViewById(R.id.tx2);
    public int mCounter=0;
    public Integer tx =15;

    btn.setOnClickListener(new View.OnClickListener() {

                               @Override
                               public void onClick(View v) {
                                   mCounter++;
                                   if(mCounter==tx){
                                      txv.setText(Integer.toString(mCounter));
                                       //reset the counter after 15 click 
                                       mCounter=0
                                   }

                               }

                           }

    );

}

}

