我以前在ListActivity
内使用此代码没有问题,现在我正在重构使用ListFragment
并且代码编译但我看不到按钮(页脚)
代码:
@Override
public void onActivityCreated(Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
log("+ ON ACTIVITY CREATED +");
listView = getListView();
// Retrieve routines ArrayList from JSON
routineList = FitnessApp.routineList;
routineList.add(new Routine("test routine"));
adapter = new GeneralTemplateAdapter(routineList, getActivity().getLayoutInflater());
listView.setAdapter(adapter);
// Creating bottom button as a footer view
Button bAddNew = (Button) getActivity().getLayoutInflater().inflate(R.layout.add_new_button, null);
bAddNew.setText("Add Routine");
listView = getListView(); // Get reference to ListActivities ListView
listView.addFooterView(bAddNew);
}
有什么想法吗?
干杯
答案 0 :(得分:4)
啊我忘记了在添加适配器之前必须声明页眉和页脚的简单事实