StatusBar不是抽象的,不会覆盖onPreferenceChange上的抽象方法

时间:2012-12-20 01:32:04

标签: java android statusbar rom

我正在处理自定义ROM,并且在尝试编译时遇到此错误。我尝试添加自定义电池选择器。

com.android.settings.pcf.StatusBar is not abstract and does not override abstract method onPreferenceChange(android.preference.Preference,java.lang.Object) in android.preference.Preference.OnPreferenceChangeListener

这是com.android.settings.pcf.StatusBar文件:

package com.android.settings.pcf;

import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceScreen;
import android.provider.Settings;

import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.R;

public class StatusBar extends SettingsPreferenceFragment implements OnPreferenceChangeListener {

    private static final String PREF_BATT_ICON = "battery_icon_list";

    ListPreference mBatteryIcon;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Load the preferences from an XML resource
        addPreferencesFromResource(R.xml.prefs_statusbar);

        mBatteryIcon = (ListPreference) findPreference(PREF_BATT_ICON);
        mBatteryIcon.setOnPreferenceChangeListener(this);
        mBatteryIcon.setValue((Settings.System.getInt(getActivity()
                .getContentResolver(), Settings.System.STATUSBAR_BATTERY_ICON,
                0))
                + "");
    }

    public boolean OnPreferenceChange(Preference preference, Object newValue) {
        if (preference == mBatteryIcon) {
            int val = Integer.parseInt((String) newValue);
            return Settings.System.putInt(getActivity().getContentResolver(),
                    Settings.System.STATUSBAR_BATTERY_ICON, val);
        }
        return false;
    }
}

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:3)

错误告诉您没有完全实现OnPreferenceChangeListener接口。特别是,onPreferenceChange方法尚未实现。

要么实现此方法,要么我实际上猜测你的意思是OnPreferenceChangeonPreferenceChange - 请注意小写“o” - (在这种情况下,我相信你还需要一个{{1}在它之前)