Android 應用程序中-設置-藍牙,若隱藏藍牙功能

Android 應用程序中-設置-藍牙,若隱藏藍牙功能

Android 應用程序中-設置-藍牙要隱藏藍牙功能步驟以下: java

1.經過搜索">Bluetooth<"找到相關的定義 android

Settings\res\values\String.xml ui

./res/values/strings.xml:206:    <string name="bluetooth">Bluetooth</string>
./res/values/strings.xml:958:    <string name="bluetooth_quick_toggle_title">Bluetooth</string>
./res/values/strings.xml:962:    <string name="bluetooth_settings">Bluetooth</string>
./res/values/strings.xml:964:    <string name="bluetooth_settings_title">Bluetooth</string>
./res/values/strings.xml:2940:    <string name="power_bluetooth">Bluetooth</string> spa

2.經過bluetooth_settings定義名字找到相關的xml文件 xml

Settings\res\xml\settings_headers.xml rem

<!-- Bluetooth -->
    <header
        android:id="@+id/bluetooth_settings"
        android:fragment="com.android.settings.bluetooth.BluetoothSettings"
        android:title="@string/bluetooth_settings_title"
        android:icon="@drawable/ic_settings_bluetooth2" /> get

3.經過ID,@+id/bluetooth_settings(R.id.bluetooth_settings)找到相關的Java文件 string

Settings\src\com\android\settings\Settings.java
it

private void updateHeaderList(List<Header> target) {//更新Header列表

    if (id == R.id.bluetooth_settings) {
                // Remove Bluetooth Settings if Bluetooth service is not available.
                if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) {
                    target.remove(header);
                } date

改成:當爲真的時候都去移除藍色選項

    if (id == R.id.bluetooth_settings) {
                // Remove Bluetooth Settings if Bluetooth service is not available.
                if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) {
                    target.remove(header);
                }

相關文章
相關標籤/搜索