0
如何在AsyncTask的子类中使用变量类型参数(我打算再次子类化)在静态上下文中使用类型参数?AsyncTask将通用类型传递给内部接口结果处理程序
例如:
public abstract class ListAsyncTask<Identifier,ListType> extends AbsAsyncTask<Identifier, List<ListType>> {
protected final String TAG = Utils.generateTag(this.getClass());
ResultListener listener;
WebProxy proxy;
String server;
public interface ResultListener {
void handleAsyncResult(List<?> result);
}
我使用的ResultListener,我想ResultListener的接口方法签名中使用类型变量“ListType”返回的AsyncTask的结果,但我不能引用它,由于接口的静态上下文作为内部接口。
我想我可以定义AsyncTask类以外的接口,但想法是让它们紧密结合。
美丽。我选择了1),我甚至没有意识到这是一种可能性。谢谢你打开我的眼睛,保罗。 – Baker
不用担心。很高兴我能帮上忙。 –