在控件ID正确的状况下,检查是否在实例化布局文件以后,获取LISTVIEW,ide
先inflate找layout下布局文件,并实例化后才能得到Listview的ID布局
demo:spa
public class FragmentPage extends Fragment {
View view = null; io
@Override
@SuppressLint("HandlerLeak")
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { class
view = inflater.inflate(R.layout.fragment_2, null); List
// @此处获取使用view.findViewById(list的ID);fragment
//最后返回加载后的布局文件
return view; layout
} demo
}文件