Я пишу DialogFragment, что отображать PreferenceFragment внутри него, но он не работает
Как заменить фрагмент с целью внутри фрагмента
SettingDialogFragment.java
package uet.dtui.megaereader;
import android.app.DialogFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
public class SettingDialogFragment extends DialogFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.layout_book_setting, container, false);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
View root = getView();
FrameLayout frame = (FrameLayout) root.findViewById(R.id.content_fm_frame);
System.out.println(frame);
/* My stub ...*/
SettingsFragment setting = new SettingsFragment();
Bundle bundle = new Bundle();
bundle.putBoolean(SettingsFragment.BOOK_SETTING_ONLY, true);
setting.setArguments(bundle);
/* */
getFragmentManager().beginTransaction()
.replace(R.id.content_fm_frame, setting)
.commit();
}
}
layout_book_setting .xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/content_fm_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Я получаю сообщение об ошибке:
No view found for id 0x7f0e0093 (uet.dtui.megaereader:id/content_fm_frame) for fragment SettingsFragment{53664f7C#2 id=0x7f0e0093}
Но System.out
заявление перед заменить все еще работают:
android.widget.FrameLayout{53539680 V.E..... ......I. 0,0-0,0
7f0e0093 app:id/content_fm_frame}
Итак, как решить эту проблему?
все еще не работает, то же ошибка – phibao37
@ user2447581 проверить мой новый ответ. – mustafasevgi