当前位置:网站首页>如何获取泛型的类型
如何获取泛型的类型
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(); } } } }
边栏推荐
- Join hands with cigent: group alliance introduces advanced network security protection features for SSD master firmware
- Swin, three degrees! Eth open source VRT: a transformer that refreshes multi domain indicators of video restoration
- 面试步骤的面试技巧
- day29 js笔记 2021.09.23
- Prefix and (2D)
- AcWing 610. Salary and bonus (implemented in C language)
- 【无标题】虚拟机vmnet0找不到且报错:没有未桥接的主机网络适配器
- js中的class类模式及语法 2021.11.10
- Intranet penetration in the working group environment: some basic methods
- Database Series: is there any way to seamlessly upgrade the business tables of the database
猜你喜欢
js中this的默认指向及如何修改指向 2021.11.09
QML control type: tabbar
Using MySQL database in the express framework of node
Many benefits of SEO optimization are directly related to traffic
Self use demo of basic component integration of fluent
Software test interview classic + 1000 high-frequency real questions, and the hit rate of big companies is 80%
开源项目维权成功案例: spug 开源运维平台成功维权
What method is required for word, PDF and txt files to realize full-text content retrieval?
Build your own website (18)
Practice and Thinking on the architecture of a set of 100000 TPS im integrated message system
随机推荐
fatal: unsafe repository (‘/home/anji/gopath/src/gateway‘ is owned by someone else)
Simple understanding of ThreadLocal
Contract quantitative trading system development | contract quantitative app development (ready-made cases)
Array method in JS 2021.09.18
Batch will png . bmp . JPEG format pictures are converted to Jpg format picture
Remote login sshd service
【JS】斐波那契数列实现(递归与循环)
Apache2 configuration denies access to the directory, but can access the settings of the files inside
day36 js笔记 ECMA6语法 2021.10.09
Necessary for beginners PR 2021 quick start tutorial, PR green screen matting operation method
Join hands with cigent: group alliance introduces advanced network security protection features for SSD master firmware
IO stream of file and Base64
Is it feasible to be a programmer at the age of 26?
AcWing 610. Salary and bonus (implemented in C language)
ArrayList源码解析
开源项目维权成功案例: spug 开源运维平台成功维权
Web page tips this site is unsafe solution
AcWing 605. Simple product (implemented in C language)
Use logrotate to automatically cut the website logs of the pagoda
【C语言】判断三角形