我正在尝试在活动onCreateView
中充气自定义视图 LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rootView = inflater.inflate(R.layout.mylayout, null);
TextView text = (TextView)rootView.findViewById(R.id.text_view);
text.setText("Hello World");
return rootView;
我收到堆栈溢出错误
答案 0 :(得分:0)
通过这种方式,我可以扩充自定义视图:)
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View layout = inflater.inflate(R.layout.fragment_hello_world, container, false);
return layout;
}