0

我正在使用 Crouton 库向用户显示警告消息。在这种情况下,我想在特定的首选项屏幕中显示。我在我的PreferenceActivity

但是,Crouton 仅显示在第一个首选项屏幕中,而不显示在实际触发 Crouton 的子首选项屏幕上。有什么想法可以解决这个问题吗?

       findPreference(key.key).setOnPreferenceChangeListener(new OnPreferenceChangeListener()
        {

            @Override
            public boolean onPreferenceChange(Preference preference, Object newValue)
            {
                int count = 0;
                for (ANALYTICS_KEYS key : ANALYTICS_KEYS.values())
                {
                    if (appPreferences.getAnalyticProperty(key))
                    {
                        count++;

                    }
                }

                Crouton crouton = null;
                if (count > 5 && count < 7)
                {
                    Style.Builder style = new Builder(Style.INFO).setConfiguration(new Configuration.Builder().setDuration(Configuration.DURATION_INFINITE).build());

                    crouton = Crouton.makeText(DashAnalyticsPreferenceActivity.this, "More than 5 attributes might not be visible", style.build());

                }
                else if (count > 7)
                {
                    crouton = Crouton.makeText(DashAnalyticsPreferenceActivity.this, "More than 7 attributes are not allowed. Only first 7 will be considered", Style.ALERT);
                }
                else
                    Crouton.cancelAllCroutons();

                if (crouton != null)
                {
                    crouton.show();
                    crouton.setOnClickListener(new View.OnClickListener()
                    {
                        @Override
                        public void onClick(View v)
                        {

                            //Crouton.hide(crouton);
                        }
                    });
                }

                return true;
            }
4

1 回答 1

1

Crouton附加到 Activity 视图。因此它只会显示在Activity已通过创建它的那个中。

如果你想Crouton在另一个中显示 a ,Activity你必须传递对应Activity的。

于 2013-12-04T12:04:42.300 回答