0

private class MyAsyncTask extends AsyncTask <String, String, String >

In this code what is the parameters in <> ? I saw the same thing in many places. But I couldn't figure what it actually mean. I'm trying to populate a listview asynchronously I'm new to android programming so please help...

4

1 回答 1

1

亲爱的,正如 Raghu 在上面提到的 URL,您应该看看 Java 泛型。

我刚刚在这里提取了一些信息。

泛型类使用以下格式定义:

班级名称 { /* ... */ }

由尖括号 (<>) 分隔的类型参数部分跟在类名之后。它指定类型参数(也称为类型变量)T1、T2、...和Tn。

要更新 Box 类以使用泛型,您可以通过将代码“public class Box”更改为来创建泛型类型声明**"public class Box <T>". This introduces the type variable, T, that can be used anywhere inside the class**.

所以在你的情况下,

AsyncTask <String, String, String >

它说.. 这三个字符串变量可以在您的 AsynTask 中使用。

希望这会有所帮助。

于 2013-11-13T11:43:31.907 回答