Java 弹出窗口不会弹出

Java 弹出窗口不会弹出,java,android,android-popupwindow,Java,Android,Android Popupwindow,我正在尝试在我的应用程序中设置PopupWindow,但它不会弹出 这是我的密码: popUp.showAtLocation(layout, Gravity.BOTTOM, 10, 10); popUp.update(50, 50, 300, 200); layout.setOrientation(LinearLayout.VERTICAL); tv.setText("Hi this is a sam

我正在尝试在我的应用程序中设置PopupWindow,但它不会弹出

这是我的密码:

popUp.showAtLocation(layout, Gravity.BOTTOM, 10, 10);
                popUp.update(50, 50, 300, 200);
                layout.setOrientation(LinearLayout.VERTICAL);
                tv.setText("Hi this is a sample text for popup window");
                tv.setTextColor(Color.BLACK);
                params= new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);          
                layout.setOrientation(LinearLayout.VERTICAL);
                layout.addView(tv,params);
                layout.addView(cl);
                layout.addView(stats);
                layout.setBackgroundColor(Color.BLUE);
                main.findViewById(R.layout.ajax);
                mainLayout.addView(check,params);                   
                popUp.setContentView(layout);
                // popUp.showAtLocation(layout, Gravity.BOTTOM, 10, 10);
                setContentView(mainLayout);
我需要做些什么才能得到这份工作和一个流行音乐


谢谢。

你可能想考虑使用AlertDialog.Builder。看,我尝试了AlertDialog,但我需要适合我的应用程序的弹出窗口。你能帮我设置弹出窗口吗?我正在尝试你在链接中给我的东西,但是这个.getSystem.Service不存在。。。我应该怎么做?这是我现在的代码:充气机=LayoutInflater context.getSystemServiceContext.LAYOUT\u充气机\u服务;popUp=新的PopupUpIndowInflater.inflateR.layout.popUp,null,false,100100,true;popUp.showtLocationFindViewByIdr.layout.ajax,Gravity.BOTTOM,0,0;但它仍然不起作用。R.layout.ajax是活动的xml,R.layout.popup是弹出窗口的xml。