我有一個簡單的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)? –
我有兩個或兩個以上的活動是項目。上面的代碼是項目的開始活動。我們在哪裏必須使用 –