由网友(殘花雪夜)分享简介:我有我的preferenceActivity出现一个菜单。在我的孩子preference屏幕,我失去了菜单(不弹出)。我怎样才能让我的菜单弹出的儿童呢?I have a menu that comes up for my PreferenceActivity. In my child preference scree...
我有我的preferenceActivity出现一个菜单。在我的孩子preference屏幕,我失去了菜单(不弹出)。我怎样才能让我的菜单弹出的儿童呢?
I have a menu that comes up for my PreferenceActivity. In my child preference screens, I lose that menu (doesn't pop up). How can I make my menu pop up for children too?
感谢。
例如:
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:persistent="true">
<PreferenceCategory
android:title="some category"
android:persistent="true"
android:orderingFromXml="true">
<PreferenceScreen
android:title="some child screen"
android:summary="some child summary">
<PreferenceCategory
...
第一preference屏幕有菜单,但是当你点击的孩子之一,没有菜单。你怎么能添加菜单?
The first preference screen has the menu, but when you click on the child one, no menu. How can you add the menu?
推荐答案
我面对类似的问题。这里是我做过什么来克服这个问题。
I faced the similar issue. Here is what I did to overcome the issue.
在preferenceActivity onCreate方法,
In the preferenceActivity onCreate method,
final PreferenceScreen childPref = (PreferenceScreen) findPreference("childPrefId");
childPref .setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference)
{
Intent intent = new Intent(PreferenceActivity.this, YourSettings.class);
intent.setAction("ShowChildPref");
startActivity(intent);
return true;
}
});
Intent intent = getIntent();
if(intent.getAction() != null && intent.getAction().equals("ShowChildPref"))
{
setPreferenceScreen(childPref);
/*Set Flags here based on intent what kind of menu to create in OnPrepareMenu.*/
}
}
相关推荐
最新文章