setCancelable财产不工作

setCancelable财产不工作

本文介绍了DialogFragment setCancelable财产不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我工作在一个Android应用程序,并正在使用DialogFragment显示一个对话框,我想做出DialogFragment不可取消。我所做的对话框取消属性设置为false,但其仍没有影响。

请看看我的code和建议我一个解决方案。

 公共类DialogTest扩展DialogFragment {

    @覆盖
    公共对话onCreateDialog(包savedInstanceState){

        返回super.onCreateDialog(savedInstanceState);
    }

    @覆盖
    公共查看onCreateView(LayoutInflater充气,容器的ViewGroup,
            捆绑savedInstanceState){
        查看查看= inflater.inflate(R.layout.dialog_test,集装箱,真正的);
        。getDialog()requestWindowFeature(STYLE_NO_TITLE);
        。getDialog()setCancelable(假);

        返回查看;
    }
 }
 

解决方案

  @覆盖
 公共查看onCreateView(LayoutInflater充气,容器的ViewGroup,
           捆绑savedInstanceState){
        查看查看= inflater.inflate(R.layout.dialog_test,集装箱,真正的);
        。getDialog()requestWindowFeature(STYLE_NO_TITLE);
        。getDialog()setCancelable(假);

        返回查看;
    }
 

而不是 getDialog()setCancelable(假); 您必须直接使用 setCancelable(假);

I am working in an android application and am using a DialogFragment to show a dialog and I want to make that DialogFragment not cancelable. I have made the dialog cancelable property to false, but still its not affecting.

Please look into my code and suggest me a solution.

public class DialogTest extends DialogFragment {

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {

        return super.onCreateDialog(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.dialog_test, container, true);
        getDialog().requestWindowFeature(STYLE_NO_TITLE);
        getDialog().setCancelable(false);

        return view;
    }
 }
解决方案
@Override
 public View onCreateView(LayoutInflater inflater, ViewGroup container,
           Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.dialog_test, container, true);
        getDialog().requestWindowFeature(STYLE_NO_TITLE);
        getDialog().setCancelable(false);

        return view;
    }

instead of getDialog().setCancelable(false); you have to use directly setCancelable(false);

这篇关于DialogFragment setCancelable财产不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 19:07