我有一个主要活动,它包含public void(string,int)和一些在主要活动中我想调用public void但我得到的错误'void checkout(string,int)不能应用于()'.. 。
这就是我称之为公共空白的方式:
main activity {
//some where in main activity
checkout(); //here i call public void but this line show error
public void checkout(String answer,int missedcallcount){
String MissedCallWhere = CallLog.Calls.TYPE + "=" + CallLog.Calls.MISSED_TYPE + " AND " + CallLog.Calls.NEW + "=1";
Cursor cmissedcallc = getApplicationContext().getContentResolver().query(CallLog.Calls.CONTENT_URI,null,MissedCallWhere, null, null);
cmissedcallc.moveToFirst();
Log.d("CALL", ""+cmissedcallc.getCount());
missedcallcount = cmissedcallc.getCount();
cmissedcallc.close();
if (missedcallcount<=5){
answer= "you have less than 5 miss call";
}else if (missedcallcount>5){
answer= "you have more than 5 miss call";
}
}
}
请帮帮我......谢谢
public void checkout(String answer,int missedcallcount)
此方法的声明显示,您需要传递两个参数才能正确调用它 - 在此示例中,如果要调用此方法,则需要将String
作为第一个参数传递给它,并将int
作为第二个参数传递给它。以下是正确调用此方法的示例:
checkout("Abcdef", 12345);
checkout(); //here i call public void but this line show error
你应该在构造函数中调用参数,在这种情况下代码应如下所示:
checkout(answer, missedCallCount);