片段放在NavigationDrawer顶部 [英] Fragment placed on top of NavigationDrawer
问题描述
我想添加一个 preferenceFragment
在我的应用程序。现在的问题是,它的自动放置在顶部我的 NavigationDrawer
。
I'm trying to add a PreferenceFragment
in my application. The problem is, it's auto placed on top of my NavigationDrawer
.
public class SetPreferenceActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.settings);
navigationDrawer(); // Loads the NavigationDrawer
getFragmentManager().beginTransaction().replace(android.R.id.content,
new Settings()).commit();
}
正如你可以看到我加载SettingsFragment和替换它的内容? (我不确定),但将其置于一切之上......这是我的设置片段。
As you can see I load the "SettingsFragment" and replace the content with it? (I'm unsure) but it places it on top of everything else.. Here's my Settings fragment.
public class Settings extends PreferenceFragment {
static final String TAG = "MAIN";
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
}
如预期的一切工作,但preferenceFragment被加载在前面,涵盖了NavigationDrawer滑出式,我打过电话 bringToFront();
在列表视图,用没有运气。
Everything work as expected, BUT the PreferenceFragment are loaded in front, covering up the NavigationDrawer slideout, I tried calling bringToFront();
on the listview, with no luck.
一个图片,以供参考:
是否有可能告诉片段加载列表视图的背后?我也因子评分加载该片段在ViewPager,但我得到一个错误,寻呼机适配器不会接受式preferenceFragment片段。
Is it possible to tell the fragment to load behind the listview? I also tought about loading the fragment in a ViewPager, but I get an error that the Pager Adapter wont accept fragments of type PreferenceFragment.
推荐答案
不要替换 android.R.id.content
,请使用该标识的FrameLayout
你有一个包含布局的 DrawerLayout
。
Don't replace android.R.id.content
, use the the id of the FrameLayout
you have in the layout that contains your DrawerLayout
.
这篇关于片段放在NavigationDrawer顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!