我的主要活动包含public void(string,int)&一些在主要活动中我想称之为公共空白,但我得到错误'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";
}
}
}
请帮助我......谢谢
答案 0 :(得分:2)
public void checkout(String answer,int missedcallcount)
此方法的声明显示,您需要传递两个参数才能正确调用它 - 在此示例中,如果要调用此方法,则需要将其作为第一个参数传递给它String
,并且{ {1}}作为第二个论点。以下是正确调用此方法的示例:
int
答案 1 :(得分:1)
checkout(); //here i call public void but this line show error
你应该在构造函数中调用参数,在这种情况下代码应该如下所示:
checkout(answer, missedCallCount);