【发布时间】:2014-05-28 19:21:19
【问题描述】:
我有两个静态方法:
public static Selector<TextView, Property<String>> textView(
final Selector<TextView, Property<TextView>> selector) {
return null;
}
public static <V extends View> Selector<V, Property<V>> withId(final int id) {
return null;
}
为什么Java编译器在调用过程中不能解析出所需的参数类型???
textView(withId(R.id.et_password));
但很容易接受这一点:
Selector<TextView, Property<TextView>> p;
textView((p = withId(R.id.et_password));
谁能提示我如何欺骗编译器?
附: class TextView extends View { ... }
【问题讨论】:
-
View是否扩展TextView? -
对,TextView 类扩展 View { ... }
标签: java android generics casting type-conversion