You have a lot of code, but I'm assuming that this is the problem:
controlsView.setOnClickListener(new View.OnClickListener() {
You give controlsView
a private OnClickListener
then expect it to handle click events from all the buttons. This will fail, since the other buttons aren't using this OnClickListener
.
Make a shared listener.
View.OnClickListener listener = new View.OnClickListener() {//..
Then pass it off to the rest of the buttons.
answerButton1.setOnClickListener (listener);
answerButton2.setOnClickListener (listener);
//etc
You can also make the Activity
implement the OnClickListener
interface.
public class MyActivity extends Activity implements OnClickListener{
@Override
public void onClick (View v)
{
//implementation
}
Then to set the OnClickListener
, you pass off the Activity
instance instead.
answerButton1.setOnClickListener (MyActivity.this);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…