English 中文(简体)
如何开始优惠 活动部分缩小等级
原标题:How to start preferenceActivity part way down the hierarchy

我是在第9级工作,因此无法利用新的优惠框架。

我的喜好活动是,按照蚊子的样子,从中选取物和Xml文档。 我有等级的优惠屏幕,非常正常,只有你才能通过顶级屏幕点击。

除了从我的主要菜单获得所有优惠外,我还要能够在一个子屏幕上而不是顶层屏幕上开始优惠活动,以便我可以直接在一个子屏幕上开始,在一组次偏好者不愿意参加的活动中点击。

Anyone know if this is posible? I would of thought that passing some data with the intent would be the way but I can not find anything saying this is possible.

最佳回答

在座的科索沃是我最后得到库尔德人的帮助。

基本上,在我开始优惠活动的法典中,如果你只想其中一部分,我就没有对所有优惠采取行动。 这一行动需要与某种类型的优惠或优惠集团的关键相匹配。

// all preferences
Intent launchPreferencesIntent = new Intent().setClass(this,
    PreferencesFromXml.class);
startActivity(launchPreferencesIntent);

// just key_trip_plot_control_preferences
Intent launchPreferencesIntent = new Intent(
    getString(R.string.key_trip_plot_control_preferences))
    .setClass(this, PreferencesFromXml.class);
startActivity(launchPreferencesIntent);

在我的普惠制班子中,我总是会增加Xml的偏好,但如果我采取行动,则我会寻求一种对应的关键。 如果我发现我放弃了所有的偏好,那么,如果它是一个优惠集团的话,就会增加配对。

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);
    String act = getIntent().getAction();

    if (act != null) {
        Preference res = findPreferenceByKey(getPreferenceScreen(), act);
        if (res != null) {
            getPreferenceScreen().removeAll();
            if (res instanceof PreferenceGroup) {
                PreferenceGroup groupe = (PreferenceGroup) res;
                // add sub items
                for (int i = 0; i < groupe.getPreferenceCount(); i++) {
                    Preference pref = groupe.getPreference(i);
                    if (pref != null) {
                        getPreferenceScreen().addPreference(pref);
                    }
                }
            } else { // just add the item.
                getPreferenceScreen().addPreference(res);
            }
        }
    }
}

protected Preference findPreferenceByKey(PreferenceGroup in, String key) {
    for (int i = 0; i < in.getPreferenceCount(); i++) {
        Preference pref = in.getPreference(i);
        if (pref == null) {
            // should not happen
            Log.v(TAG, "findPreferenceByKey null pref i:" + i);
            return null;
        } else if (pref.hasKey() && pref.getKey().equals(key)) {
            return pref;
        } else if (pref instanceof PreferenceGroup) {
            // recurse
            Preference res = findPreferenceByKey((PreferenceGroup) pref,
                    key);
            if (res != null) {
                return res;
            }
        }
    }
    return null;
}
问题回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签