I want a code like the following for loading PreferenceFragment
into Fragment:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
int inx = getArguments().getInt("index", 0);
View view;
switch (inx){
case 0:
view = inflater.inflate(R.layout.a, container, false);
break;
case 1:
view = inflater.inflate(R.layout.b, container, false);
break;
case 2:
view = MyPreferenceFragment();
break;
default:
view = inflater.inflate(R.layout.a, container, false);
}
return view;
}
Try adding the following to case 2:
getFragmentManager().beginTransaction().replace(android.R.id.content,new {YourSettingsClass} ()).commit();
and declare the fragment in the activity layout.
Check this out for more info How to Load PreferenceFragment in Fragment
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.