【发布时间】:2014-08-13 15:57:57
【问题描述】:
如何设置 android 弹出窗口在后台运行。我的意思是,我不需要打开应用程序,但它会在后台运行,并且当调用时,弹出窗口会出现在 android 主菜单上。我得到了handler 脚本,我只想知道如何设置此弹出窗口以显示在任何屏幕上,就像toast message 一样。
LayoutInflater layoutInflater = (LayoutInflater)MainActivity.this.getSystemService(LAYOUT_INFLATER_SERVICE);
final View popupView = layoutInflater.inflate(R.layout.popup, null);
final PopupWindow popupWindowDi = new PopupWindow(popupView, LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
Button btnDismiss = (Button)popupView.findViewById(R.id.dismiss);
btnDismiss.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v) {
popupWindowDi.dismiss();
}});
popupWindowDi.showAsDropDown(btnOpenPopup, 50, -30);
【问题讨论】:
标签: android popupwindow