添加警报窗口后,DialogFragment未显示

时间:2015-02-05 19:39:17

标签: android android-dialogfragment dialogfragment system-alert-window

我有一个函数,当触发时,成功显示带有以下代码的DialogFragment

DialogFragment

DialogFragment dialog;
View dialogView;
Context activityContext;

...

dialog = new DialogFragment(){
   @Override public Dialog onCreateDialog(Bundle savedInstanceState) {
      dialogView = getActivity().getLayoutInflater().inflate(R.layout.customView, null);
      ...
      AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
      builder.setView(dialogView);
      return builder.create();
   }
};

dialog.show(activityContext.getSupportFragmentManager() , "MyDialog");

问题是,在我添加一个带有以下代码的系统警报窗口后,DialogFragment不再显示,但是如果我传递给另一个应用程序,当我的应用程序最小化时,我可以看到DialogFragment,同时减少它的大小

系统警报窗口

WindowManager mWindowManager;
WindowManager.LayoutParams params;

...

mWindowManager = (WindowManager)activityContext.getSystemService(Context.WINDOW_SERVICE);
params = new WindowManager.LayoutParams(
   WindowManager.LayoutParams.WRAP_CONTENT,
   WindowManager.LayoutParams.WRAP_CONTENT,
   WindowManager.LayoutParams.TYPE_PHONE,
   WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
   PixelFormat.TRANSLUCENT
}
params.gravity = Gravity.CENTER_VERTICAL | Gravity.RIGHT;
addView(((LayoutInflater)activityContext.getSystemService("layout_inflater")).inflate(R.layout.floatingBotton, null));

所以...为什么我不能在顶部看到我的对话框(据我所知,对话框正在显示) 为什么只在显示系统警报窗口时才会发生

我已尝试使用系统警报窗口的其他标志,但我遇到了与我尝试过的问题相同的问题

2 个答案:

答案 0 :(得分:0)

Count(distinct l.CompDate) As Submitted,

Count(distinct date(l.CompDate)) As Submitted,

请尝试这可能有用

答案 1 :(得分:0)

specify the view group ing inflate and set attach to root to true

http://developer.android.com/reference/android/view/LayoutInflater.html#inflate(int, android.view.ViewGroup, boolean)

addView(((LayoutInflater)activityContext.getSystemService("layout_inflater")).inflate(R.layout.floatingBotton, null));