2012-03-28 78 views
0

如何在運行時從PreferenceScreen中刪除ListPreference?
父行上的某些東西像setVisibility(Visibility.GONE)。從PreferenceScreen中隱藏/刪除ListPreference

public class PreferencesActivity extends PreferenceActivity 
{ 
    protected void onConfigurationChanged(ApplicationConfiguration config) 
    { 
     // ... 
     if(config.actualAccounts.sie() < 1) 
     { 
      ListPreference p = (ListPreference) findPreference("account"); 
      p.setEnabled(false); 
      // here I want to hide it at all 
     } 
     // .... 
    } 
} 

回答

0

我是啞巴..

final PreferenceScreen preferenceScreen = getPreferenceScreen(); 
// ... 
if(config.actualAccounts.sie() < 1) 
{ 
    preferenceScreen.removePreference((ListPreference) findPreference("account")); 
}