单击侦听器时出错

时间:2016-06-04 13:55:43

标签: android onclick

    sadButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v){
                Intent response = new Intent(MainActivity.this, UserResponse.class);
                startActivity(response);
            }
        }

错误: setonClickListener(无法解析符号),无法解析符号v

之前我尝试过这段代码,但没有任何错误。那么这里有什么问题?

1 个答案:

答案 0 :(得分:0)

just add ); in the end like this


sadButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v){
                Intent response = new Intent(MainActivity.this,UserResponse.class);
                startActivity(response);
            }
        });