OnClick Listener Is Not Function As Expected

前端 未结 1 2055
猫巷女王i
猫巷女王i 2021-01-26 16:48

I have an onClickListener set on a TextView (mReadAgainButton) which is supposed to reload a set of instructions from the beginning (initi

相关标签:
1条回答
  • 2021-01-26 17:07

    It is a bad idea to compare objects with the == operator. Try something like this instead:

    public void onClick(View v) {
        switch(v.getId()) {
            case R.id.yourButton:
                switch(mInstructionNumber) {
                    case 0:
                    case 1:
                    ...
                }
            case R.id.ofmAssistInstrButton:
            case R.id.ofmAssistInstrButton: //I think you made a typo here since they are the same name
            default:
                //your else statement stuff
            ...
        }
    }
    
    0 讨论(0)
提交回复
热议问题