我把我的頭髮拉出看起來很簡單的事情。當然這只是一個錯字或一些愚蠢的事,但我只是沒有看到它......Android ASyncTask返回類型不匹配
我有一個的AsyncTask類定義的那樣(和它編譯罰款)
public class SectionRetrieval extends AsyncTask<Void, Void, List<Section>>
{
@Override
protected List<Section> doInBackground(Void... voids)
{
List<Section> sections = new ArrayList<Section>();
...
return sections;
}
}
在我的應用我嘗試將它稱作爲這樣
List<Section> sections = new SectionRetrieval().execute();
但是,這並不編譯
Error:(472, 63) Gradle: error: incompatible types:
AsyncTask<Void,Void,List<Section>> cannot be converted to List<Section>
我已經試過分離CR新的SectionalRetrieval實例的實例和調用.execute()。沒有這樣的運氣。它似乎確實認爲execute()實際上是試圖返回SectionalRetrieval的一個實例。
那麼我是怎麼認爲這就是我想要的?
看到這個答案http://stackoverflow.com/a/10972142/3629732但這個不建議性能問題 –