Custom Layout for DialogFragment OnCreateView vs. OnCreateDialog

后端 未结 6 1603
庸人自扰
庸人自扰 2020-12-01 00:31

I\'m trying to create a DialogFragment using my own Layout.

I\'ve seen a couple different approaches. Sometimes the layout is set in OnCreateDialog like this: (I\'

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-01 01:12

    This first approach works for me... until I want to use FindViewByID.

    I would guess that you are not scoping findViewById() to the View returned by inflate(), try this:

    View view = i.inflate(Resource.Layout.frag_SelectCase, null);
    // Now use view.findViewById() to do what you want
    b.setView(view);
    
    return b.create();
    

提交回复
热议问题