fragment.onCreateView causes null pointer exception

前端 未结 3 430
小蘑菇
小蘑菇 2021-01-13 19:41

So i am using fragments and trying to wire on click listeners on them.

public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bun         


        
3条回答
  •  星月不相逢
    2021-01-13 20:23

    simply use this in your onCreateView

        View contentView = inflater.inflate(R.layout.layout1, container, false);
        startButton= (Button) contentView.findViewById(R.id.button);
        return contentView;
    

提交回复
热议问题