简体   繁体   中英

How to Load PreferenceFragment in Fragment

I have divided main activity in two Fragments,

the upper Portion loads the Button from xml,

& i want to load PreferenceFragment in thr Lower Portion ,

How to do that ??

I tried calling the Settings.class which extends PreferenceFragment directly using the following code in my Lower Portion Fragment

getFragmentManager().beginTransaction().replace(android.R.id.content,new Settings ()).commit();

That calls the PreferenceFragment but it Overlaps the upper Portion,

I am trying to achieve something like this

在此处输入图片说明

You can declare the fragments in the activity's layout file.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <fragment android:name="com.example.news.ArticleListFragment"
        android:id="@+id/list"
        android:layout_weight="1"
        android:layout_width="0dp"
        android:layout_height="match_parent" />
    <fragment android:name="com.example.news.ArticleReaderFragment"
        android:id="@+id/viewer"
        android:layout_weight="2"
        android:layout_width="0dp"
        android:layout_height="match_parent" />
</LinearLayout>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM