从documentation here我们可以看到它是org.apache.http.NameValuePair
,因此查看原始documentation given here at apache.org,它有构造函数:
public NameValuePair(String name,
String value)
但我也想存储其他数据类型值,如boolean和int。我怎么能这样做?
答案 0 :(得分:0)
NameValuePair
的 org.apache.http
和其他已弃用的类已完全在API级23
中删除。
您可以使用android.util.Pair
,它使用泛型并允许您存储任何数据类型,例如:
// stores boolean values
Pair<String, Boolean>> p1 = new Pair<>("key", false));
// stores int values
Pair<String, Integer>> p2 = new Pair<>("key", 1));