Android系統rom開發過程中,由于項目需求,需隐藏(屏蔽)設定中“模拟顔色空間”條目,采用的暴力隐藏方式解決,大體思路是找到對應布局檔案,将對應布局删除,并将源碼中調用位置代碼删除,具體如下:
1、apps/Settings/res/xml/development_prefs.xml中
<!--<ListPreference
android:entries="@array/simulate_color_space_entries"
android:entryValues="@array/simulate_color_space_values"
android:key="simulate_color_space"
android:persistent="false"
android:summary="%s"
android:title="@string/simulate_color_space" />-->
2、apps/Settings/src/com/android/settings/DevelopmentSettings.java中需要屏蔽的代碼如下
//private static final String SIMULATE_COLOR_SPACE = "simulate_color_space";
onCreate方法
//mSimulateColorSpace = addListPreference(SIMULATE_COLOR_SPACE);
updateAllOptions方法
//updateSimulateColorSpace();
resetDangerousOptions方法
// Only poke the color space setting if we control it.
onPreferenceChange方法
由于當時項目催的緊,就直接用了這種方式,個人不推薦這種方式,采用removePreference()會更為優雅
。