错误:/home/gabr0/Escritorio/Andorid/packages/apps/OwlsNest/src/com/aosip/owlsnest/advanced/ScreenStateToggles.java:187.26:AlertDialog类型中的方法setPositiveButton(int,DialogInterface.OnClickListener) .Builder不适用于参数(int,new OnclickListener(){}) 错误:/home/gabr0/Escritorio/Andorid/packages/apps/OwlsNest/src/com/aosip/owlsnest/advanced/ScreenStateToggles.java:187.83:DialogInterface无法解析为某种类型 错误:/home/gabr0/Escritorio/Andorid/packages/apps/OwlsNest/src/com/aosip/owlsnest/advanced/ScreenStateToggles.java:188.41:DialogInterface无法解析为某种类型 错误:/home/gabr0/Escritorio/Andorid/packages/apps/OwlsNest/src/com/aosip/owlsnest/advanced/ScreenStateToggles.java:195.88:DialogInterface无法解析为某种类型 错误:/home/gabr0/Escritorio/Andorid/packages/apps/OwlsNest/src/com/aosip/owlsnest/advanced/ScreenStateToggles.java:196.49:DialogInterface无法解析为类型
代码
if (value == true){
AlertDialog.Builder builder = new AlertDialog.Builder(mContext,android.R.style.Theme_Material_Dialog_Alert);
builder.setTitle(R.string.screen_state_twogtitle)
.setMessage(R.string.screen_state_twogmessage)
.setPositiveButton(R.string.screen_state_twogconnect, new DialogInterface.OnclickListener() {
public void onClick(DialogInterface dialog, int which) {
Settings.System.putInt(resolver, Settings.System.SCREEN_STATE_TWOG, value ? 1 : 0);
Intent intent = new Intent("android.intent.action.SCREEN_STATE_SERVICE_UPDATE");
mContext.sendBroadcast(intent);
}})
.setNegativeButton(R.string.screen_state_twogdontconnect, new DialogInterface.OnclickListener(){
public void onClick(DialogInterface dialog, int which){
value = !value;
}
})
.show();}return true;}
答案 0 :(得分:0)
在您的setPositiveButton()
和setNegativeButton()
来电中,您已尝试使用DialogInterface.OnclickListener
。这个类的正确名称是DialogInterface.OnClickListener
,大写"点击"。
答案 1 :(得分:0)
.setPositiveButton(R.string.screen_state_twogconnect/*wrong perameter*/, new
DialogInterface.OnclickListener() {
R.string.screen_state_twogconnect不是字符串,而是对整数的引用。您可能必须将字符串放在“字符串”等位置。
你可以这样说
.setPositiveButton("the value of twogconnect" , new
DialogInterface.OnclickListener() {