I would like to display a Popup Window when the activity is created. I have followed other posts regarding this which recommend putting some of the code within a post method. Currently i have;
final PopupWindow poppers = new PopupWindow(this);
final View popLayout = getLayoutInflater().inflate(R.layout.content_popup, null);
poppers.setContentView(popLayout);
poppers.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
poppers.setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
poppers.setBackgroundDrawable(new BitmapDrawable());
poppers.setFocusable(true);
poppers.setOutsideTouchable(true);
poppers.setElevation(3);
popLayout.post(new Runnable(){
public void run() {
poppers.showAtLocation(llMain, Gravity.CENTER, 0, 0);
}
The code within run() is never hit. Any ideas why this could be?
Call it as below
llMain.post(new Runnable(){
public void run() {
poppers.showAtLocation(llMain, Gravity.CENTER, 0, 0);
}
instead of popLayout use your rootView.