我最近从 Python 迁移到 Android,但被困在这里。
这是我的类声明,用于为接受必要参数的警报对话框创建一个通用函数:
public static AlertDialog.Builder getAlertDialog(String strArray[],
String strTitle, Activity v) {
return new AlertDialog.Builder(v)
.setTitle(strTitle).setItems(strArray,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
});
}
但我无法通过这段代码调用这个函数,这给了我一个错误:
getAlertDialog(strArray, strTitle, MakeCall.class).show();
错误是:
the method getAlertDialog(String[], String, Activity) in the type MakeCallAlertDialog is not applicable for the arguments (String[], String, Class<TestActivity>)
我怎样才能正确地得到这个?