当前位置:网站首页>如何获取泛型的类型
如何获取泛型的类型
2022-06-28 11:38:00 【一杯苦芥】
@Override
public void loadImage(@NonNull Context context, @Nullable String url, @Nullable Options options, @Nullable ILoaderListener<T> listener) {
Type type = listener.getClass().getGenericInterfaces()[0];
//若type是ParameterizedType的实例, 则强转,ParameterizedType可以得到泛型的类型
if (type instanceof ParameterizedType) {
ParameterizedType pType = (ParameterizedType) type;
Type[] types = pType.getActualTypeArguments();
if (types != null && types.length > 0) {
Class clazz = (Class) types[0];
try {
Log.e("test", types[0].equals(Drawable.class));
Log.e("test", clazz.equals(Drawable.class));
} catch (Exception e) {
e.printStackTrace();
}
}
}
}边栏推荐
- js中的class类模式及语法 2021.11.10
- Day36 JS notes ecma6 syntax 2021.10.09
- Join hands with cigent: group alliance introduces advanced network security protection features for SSD master firmware
- . Net hybrid development solution 24 webview2's superior advantages over cefsharp
- Convert black mask picture to color annotation file
- Class pattern and syntax in JS 2021.11.10
- MapReduce项目案例3——温度统计
- Excel import / export convenience tool class
- MapReduce project case 1
- What method is required for word, PDF and txt files to realize full-text content retrieval?
猜你喜欢

【C语言】关于scanf()与scanf_s()的一些问题

【C语言】结构体嵌套二级指针的使用

【C语言】判断三角形
Using MySQL database in the express framework of node

Swin, three degrees! Eth open source VRT: a transformer that refreshes multi domain indicators of video restoration

【C语言】NextDay问题
![[Beijing University of Aeronautics and Astronautics] information sharing for the first and second examinations of postgraduate entrance examination](/img/06/df5a64441814c9ecfa2f039318496e.jpg)
[Beijing University of Aeronautics and Astronautics] information sharing for the first and second examinations of postgraduate entrance examination

day33 js笔记 事件(下)2021.09.28

Multi dimensional monitoring: the data base of intelligent monitoring

day31 js笔记 DOM下 2021.09.26
随机推荐
来吧元宇宙,果然这热度一时半会儿过不去了
【C语言】如何产生正态分布或高斯分布随机数
建立自己的网站(18)
The default point of this in JS and how to modify it to 2021.11.09
Interview skills for interview steps
Swin, three degrees! Eth open source VRT: a transformer that refreshes multi domain indicators of video restoration
JS foundation 8
AcWing 610. Salary and bonus (implemented in C language)
IO stream of file and Base64
Practice and Thinking on the architecture of a set of 100000 TPS im integrated message system
day33 js笔记 事件(下)2021.09.28
Day39 prototype chain and page Fireworks Effect 2021.10.13
【C语言】NextDay问题
【sciter】: sciter-fs模块扫描文件API的使用及其注意细节
SoapUI rookie tutorial
Day24 JS notes 2021.09.15
Day39 prototype chain and page fireworks effect 2021.10.13
Allez, Meta - Cosme, comme prévu, cette chaleur ne durera pas longtemps.
Zero basic C language (I)
.NET混合开发解决方案24 WebView2对比CefSharp的超强优势