I have 4 buttons on my layout. One is the “Correct Answer” and 3 are “WRONG Answers”
I have coded a common method for my WRONG answer, but the code requires me to push the different button names in that piece of code. How do i manage that?
This is my code
/* call method for a answer */
final Button rredButton=(Button)findViewById(R.id.RredButton);
rredButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
LayoutInflater layoutInflater
= (LayoutInflater)getBaseContext()
.getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = layoutInflater.inflate(R.layout.popupright, null);
final PopupWindow popupWindow = new PopupWindow(
popupView,
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
Button btnNxtScr = (Button)popupView.findViewById(R.id.nextscreen);
btnNxtScr.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v) {
Intent myintent1 = new Intent(colorActivity.this,LearningTimeMenu.class);
startActivity(myintent1);
}
});
popupWindow.showAsDropDown(rredButton, 50, -300);
}});
I tried to do this
final Button rblueButton=(Button)findViewById(R.id.RblueButton);
rblueButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
createWrongPop();
}});
and define the layout inflator part of the code in the createWrongPop() method; but this line of code
popupWindow.showAsDropDown(rredButton, 50, -330) expects the button ID for each of the 3 buttons.
How do i pass each of the variables to the method?
Accept parameter in
createWrongPop()method and pass the view received in theonClickmethod: