为什么我写了个类似的会栈溢出
public class FoodFregment extends Fragment {
/*
* 第一个页面的控件声明
*/
private ListView foodList;
private ArrayAdapter<String> arrAdapt;
/*
* 对应相对的View
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// 导入tab01
View view = inflater.inflate(R.layout.tab01, container);
// 初始化ListView
foodList = (ListView) getActivity().findViewById(R.id.food_list);
//创建数据源
String[] foods = { "No1", "No2", "No3", "No4", "No5", "No6", "No7"};
// 新建适配器(上下文、列表样式、数据源)
arrAdapt = new ArrayAdapter<String>(getActivity(),
android.R.layout.simple_expandable_list_item_2, foods);
// 加载数据源
foodList.setAdapter(arrAdapt);
return view;
}
}
报错就是栈溢出(或者叫内存溢出)……求解