خرید بک لینک

Vote count: 0

I'm wondering how to make multiple buttons, which have the ability to go back after a certain amount of clicks. when i hit the third incorrect button it doesn't go back. please can someone tell me where im going wrong.

private boolean answer = false;
private int tusLeft = 0;
Button btn1;
Button btn2;
Button btn3;
Button btn4;

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

    btn1 = (Button) findViewById(R.id.btn1);
    btn1.setOnClickListener(this);

    btn2 = (Button) findViewById(R.id.btn2);
    btn2.setOnClickListener(this);

    btn3 = (Button) findViewById(R.id.btn3);
    btn3.setOnClickListener(this);

    btn4 = (Button) findViewById(R.id.btn4);
    btn4.setOnClickListener(this);


}

public void onClick (View view){
    switch (view.getId()){
        case R.id.btn1: {
            Intent intent  = new Intent(Cat.this,Congratulations.class);
            startActivity(intent);
            break;
        }
        case R.id.btn2: {
           animalButtonClicked(btn2,tusLeft);
            break;
        }
        case R.id.btn3: {
            animalButtonClicked(btn3,tusLeft);
            break;
        }
        case R.id.btn4: {
            animalButtonClicked(btn4,tusLeft);
            break;
        }
        default:{
            break;
        }
    }
}

private int animalButtonClicked(Button button, int count){
    button.setEnabled(false);
    count++;


    if(count == 3){
        count = 0;
        finish();
    }
    button.setEnabled(false);
    retu count;
}

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 13 ارديبهشت 1395 ساعت: 19:40

صفحه بندی