Dans mon activité parent j'ai un bouton, quand je clique dessus, il affiche PopUpWindow avec 2 ImageButton .. Lorsque ce PopUpWindow existe, je ne peux pas cliquer sur mon bouton d'activité parent .. Voici mon code, est-il un problème dans ce ..Impossible de cliquer sur le bouton d'activité parent lorsque PopupWindow montrant
public class PopUpExample extends Activity {
Button but;
LinearLayout mainLayout;
PopupWindow popUp;
boolean click = true;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mainLayout = (LinearLayout) findViewById(R.id.main_layout);
but = (Button) findViewById(R.id.main_btn);
but.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
View popView;
if(click){
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
popUp = new PopupWindow(inflater.inflate(R.layout.popup_example, null, false),100, 50, true);
popUp.showAtLocation(mainLayout, Gravity.CENTER, 0, 0);
popUp.update();
click = false;
popView = popUp.getContentView();
ImageButton call = (ImageButton) popView.findViewById(R.id.call_btn);
call.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Toast.makeText(PopUpExample.this, "Calling...", Toast.LENGTH_SHORT).show();
}
});
ImageButton sms = (ImageButton) popView.findViewById(R.id.sms_btn);
sms.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Toast.makeText(PopUpExample.this, "Sms...", Toast.LENGTH_SHORT).show();
}
});
}else{
popUp.dismiss();
click = true;
}
}
});
}
}
Utilisez simplement popupWindow.setFocusable (false); , popwindow rejeter et vue en arrière-plan cliquer avec fonctionnera en même temps. –