我正在eclipse中开发一个Android应用程序,这就是我在主要活动中调用的内容:
new PhotoUpdate(app).execute(Pair.create(PhotoUpdate.PARAM_FILE, photoPath));
我的AsyncTask类看起来像这样:
public class PhotoUpdate extends AsyncTask<Pair<String, String>, Void, String> {
//some code
@Override
protected String doInBackground(Pair<String, String>...params) {
//delegate functionality to some other methods
}
}
然而,在我的活动中,我遇到了一个编译器错误,我调用了执行文件:
The method execute(Pair<String,String>...) in the type
AsyncTask <Pair<String,String>,Void,String> is not applicable for the arguments
(Pair<String,String>)
这些是它提供的快速修复:
Essentialy它抱怨我不能将一对字符串传递给一个需要多对字符串的函数,这没有意义。有没有人看到过这个错误?
答案 0 :(得分:0)
解决了问题!
我在我的项目中使用了一个支持库,PhotoUpate
类中的Pair对象和我以前调用execute的Pair对象来自不同的库(一个来自支持库,来自android库)
答案 1 :(得分:0)
'配对...'这意味着您必须发送一个'pair'数组,并且您将使用params [0]在doinbackground上获取数据,您可以使用构造函数,而不是更好。