代码改变世界
Fragment控件初始化
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_dynamic, container, false);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
init();
}
private void init() {
placeAddFriend = (TextView) getActivity().findViewById(R.id.placeAddFriend);
}
把view.findViewById变成getActivity.findViewById
这样就可以在下面别的方法初始化控件了
实现