我有一个简单的android应用程序,它是动态创建列表并添加到FragmentManager。列表类是指包含合并布局的布局项目。整个应用程序正在使用SherlockFragmentActivity。如何在Android现有的应用程序添加一个简单的页面
现在我想添加一个永久页脚到现有的FragmentManager而不会影响当前的功能。
这个页脚应该可用的所有页面。
任何人都可以请帮我这么做吗?
这里是在Java代码:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FragmentManager fm = getSupportFragmentManager();
// Create the list fragment and add it to sole content.
if (fm.findFragmentById(android.R.id.content) == null) {
ClockListFragment list = new ClockListFragment();
fm.beginTransaction().add(android.R.id.content, list).commit();
//adding the list to the content
}
}
这里ClockListFragment是被添加的内容类:
public static class ClockListFragment extends SherlockListFragment implements
LoaderManager.LoaderCallbacks<Cursor>, PauseSource {
variablesdeclarations.......
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setEmptyText(getText(R.string.no_clock_defined));
setHasOptionsMenu(true);
mAdapter = new ClockCursorAdapter(getActivity(), R.layout.world_clock_item, null, this);
setListAdapter(mAdapter);
setListShown(false);
ListView listView = getListView();
setupCabOld(listView);
registerPreferenceChanged();
if (savedInstanceState != null) {
// Restore contextual action bar state
CharSequence cab = savedInstanceState.getCharSequence(CAB);
if (cab != null) {
mMode = getSherlockActivity().startActionMode(new ModeCallback());
mMode.setTitle(cab);
mMode.invalidate();
}
}
getLoaderManager().initLoader(0, null, this);
Clocks.updateOrder(getActivity());
updateWeather(false);
}
........ other codes
}
您是否尝试过用'addFooterView()的['ListView'类]的'方法(http://developer.android.com/reference/android/widget/ListView。 HTML)? –
我有两个或两个以上的活动是项目。上面的代码是项目的开始活动。我们在哪里必须使用 –