我是 Android 编程的新手,我的第一个项目是 Xposed 模块,这个 xposed 模块有一个选项,当它启用时,它会更改一个可绘制文件,现在好吗?我遇到的问题是在公共 void handleInitPackageResources 中使用“onCheckedChanged”。
我有很多错误,我不明白为什么/如何解决它,这是我的代码:
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.content.res.XModuleResources;
import de.robv.android.xposed.IXposedHookInitPackageResources;
import de.robv.android.xposed.IXposedHookZygoteInit;
import de.robv.android.xposed.callbacks.XC_InitPackageResources.InitPackageResourcesParam;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.Switch;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public class CustomHeaderImage implements IXposedHookZygoteInit, IXposedHookInitPackageResources {
private String MODULE_PATH = null;
@Override
public void initZygote(StartupParam startupParam) throws Throwable {
MODULE_PATH = startupParam.modulePath;
}
@Override
public void handleInitPackageResources(InitPackageResourcesParam resparam) throws Throwable {
if (!resparam.packageName.equals("com.android.systemui"))
return;
///////the place of the switch
////If Enabled Do The Following :
Switch applybutton = (Switch)findViewById(R.id.switch1);
applybutton.setOnClickListener(new CompoundButton.OnCheckedChangeListener(){
public void onCheckedChanged extends AppCompatActivity(CompoundButton R.id.switch1, boolean on)
{
if (on) {
XModuleResources modRes = XModuleResources.createInstance(MODULE_PATH, resparam.res);
resparam.res.setReplacement("com.android.systemui", "drawable", "notification_header_bg", modRes.fwd(R.drawable.notification_header_bg));
} else {
}
} }
};
}