Reputation:
I am working with android.I used to create a poupup form in xml which popups by clicking the button on the mail xml file.But It force closes the application.No error in my code. I cant find out my error. Here is my code:
imageButton2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
View popUpView = getLayoutInflater().inflate(R.layout.popup, null); // inflating popup layout
mpopup = new PopupWindow(popUpView, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, true); //Creation of popup
mpopup.showAtLocation(popUpView, Gravity.BOTTOM, 0, 0); // Displaying popup
ImageButton Sub = (ImageButton) findViewById(R.id.submit);
Sub.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mpopup.dismiss();
}
});
}
});
Upvotes: 1
Views: 203
Reputation: 47817
Replace this:
ImageButton Sub = (ImageButton) findViewById(R.id.submit);
With below:
ImageButton Sub = (ImageButton) popUpView.findViewById(R.id.submit);
If i am not wrong then try out this.
Upvotes: 1