How to setContentView in a fragment?

前端 未结 5 1825
说谎
说谎 2020-11-29 05:53

Now I\'ve got this fragment which i want to use setContentView with but so far i cant find how. You can see my case in the code below, im not trying to inflate a layout, im

5条回答
  •  难免孤独
    2020-11-29 06:22

    You dont call setContentView in fragments, in fact you need to return a View from onCreateView.

    Try replacing:

    setContentView(new SampleView(this));
    

    With this:

    return new SampleView(this);
    

提交回复
热议问题