Problem inflating custom view for AlertDialog in DialogFragment

后端 未结 9 2368
忘了有多久
忘了有多久 2020-11-27 04:43

I\'m trying to create a DialogFragment using a custom view in an AlertDialog. This view must be inflated from xml. In my DialogFragment

9条回答
  •  死守一世寂寞
    2020-11-27 05:02

    I haven't inflated from XML but I have done dynamic view generation in a DialogFragment successfully:

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        m_editText = new EditText(getActivity());
        return new AlertDialog.Builder(getActivity())
                .setView(m_editText)
                .setPositiveButton(android.R.string.ok,null)
                .setNegativeButton(android.R.string.cancel, null);
                .create();
    }
    

提交回复
热议问题