如何调用 public void(int i,string s)
How to call public void(int i,string s)
我有 main activity,它包含 public void(string,int) 和 main activity 中的一些地方,我想调用 public void 但是我得到错误 'void checkout(string,int) cannot be applied to ()'...
我就是这样称呼我的 public void:
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";
}
}
}
请帮助我...谢谢
checkout(); //here i call public void but this line show error
您应该在构造函数中调用参数,在这种情况下代码应如下所示:
checkout(answer, missedCallCount);
public void checkout(String answer,int missedcallcount)
此方法的声明表明,您需要传递两个参数才能正确调用它 - 在本例中,如果您想调用此方法,您需要将 String
作为第一个参数传递给它,和 int
作为第二个参数。下面是正确调用该方法的例子:
checkout("Abcdef", 12345);
我有 main activity,它包含 public void(string,int) 和 main activity 中的一些地方,我想调用 public void 但是我得到错误 'void checkout(string,int) cannot be applied to ()'...
我就是这样称呼我的 public void:
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";
}
}
}
请帮助我...谢谢
checkout(); //here i call public void but this line show error
您应该在构造函数中调用参数,在这种情况下代码应如下所示:
checkout(answer, missedCallCount);
public void checkout(String answer,int missedcallcount)
此方法的声明表明,您需要传递两个参数才能正确调用它 - 在本例中,如果您想调用此方法,您需要将 String
作为第一个参数传递给它,和 int
作为第二个参数。下面是正确调用该方法的例子:
checkout("Abcdef", 12345);