Tell me what's wrong, the buttons do not react to pressing!

View.OnClickListener onClickListener = new View.OnClickListener() { @Override public void onClick(View v) { switch (v.getId()){ case R.id.btnRed : Toast.makeText(getApplicationContext(),"Red",Toast.LENGTH_LONG).show();break; case R.id.btnGreen : Toast.makeText(getApplicationContext(),"Green",Toast.LENGTH_LONG).show();break; case R.id.btnBlue : Toast.makeText(getApplicationContext(),"Blue",Toast.LENGTH_LONG).show();break; } } }; 
  • What is your View? - Alexey Shtanko

1 answer 1

Is your onClickListener substituted into the setOnClickListener of the desired View? View.html # setOnClickListener

  • For sure! My inattention. Thank you! - quaresma89