我之前发送过这个问题,但我删除了它,因为我要粘贴更多代码。
我的问题是单击时出现 PopupUpWindow 并出现 2 个按钮。因此,这两个按钮具有 OnClick,但没有任何反应。我要粘贴我的代码:
// PopupWindow de Exit
Button exit=(Button) findViewById(R.id.button1);
popUpView = getLayoutInflater().inflate(R.layout.estadisticaspopupwindowexit, null);
mpopup = new PopupWindow(popUpView, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, true);
exit.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
System.out.println("no clicked");//For checking that it's ok
mpopup.showAtLocation(popUpView, Gravity.BOTTOM, 0, 0);
// UNTIL HERE IT'S OK
View viewexit = (LinearLayout) factory.inflate(R.layout.estadisticaspopupwindowexit, null);
Button si=(Button) viewexit.findViewById(R.id.buttonyes);
Button no=(Button) viewexit.findViewById(R.id.buttonno);
// THESE ARE BUTTONS CALLED FROM ANOTHER XML FILE
si.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Intent intencion=new Intent(estadisticas.this, datosusuario.class);
startActivity(intencion);
}
});
no.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
mpopup.dismiss();
System.out.println("no clicked");
// I'M WRITING THE LAST THING FOR CHECKING ON MY LOGCAST IF IT REALLY WORKS, BUT NOTHING HAPPENS
}
});
}
});
这就是一切。谢谢