Je travaille sur l'application où je dois montrer Popup dans mon activité principale, en Pop up J'ai un bouton sur lequel j'ai besoin d'effectuer une opération.Événement OnClick sur la fenêtre popup dans Android
S'il vous plaît voir mon code ci-dessous. Le code ne donne pas d'erreur mais le bouton de la fenêtre contextuelle ne fonctionne pas.
imgOpenPopup = (ImageView) findViewById(R.id.places);
imgOpenPopup.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
LayoutInflater inflater = (LayoutInflater) ConvergeActivity.this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View popupView = inflater.inflate(R.layout.placepopup,(ViewGroup)findViewById(R.layout.maincam));
popupWindow = new PopupWindow(inflater.inflate(
R.layout.placepopup, null, false), 200, 265, true);
popupWindow.showAtLocation(findViewById(R.id.places),
Gravity.CENTER, 0, 0);
objbtnpopupOk=(Button)popupView.findViewById(R.id.btnokpopup);
objbtnpopupOk.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
Toast.makeText(getApplicationContext(), " hi thrtrt " ,Toast.LENGTH_LONG).show();
}
});
}
});
Essayez d'appeler popupWindow.showAtLocation ... après objbtnpopupOk.setOnClickListener ... – Pasha
Aucun travail n'a pas fonctionné pour moi. – kendrelaxman