当前位置:网站首页>How to get a generic type
How to get a generic type
2022-06-28 12:11:00 【A cup of bitter mustard】
@Override
public void loadImage(@NonNull Context context, @Nullable String url, @Nullable Options options, @Nullable ILoaderListener<T> listener) {
Type type = listener.getClass().getGenericInterfaces()[0];
// if type yes ParameterizedType Example , Then strong rotation ,ParameterizedType Can get generic types
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();
}
}
}
}边栏推荐
- SoapUI rookie tutorial
- Open3d manual clipping point cloud
- Graphics view framework for QT learning (to realize startup animation)
- day25 js中的预解析、递归函数、事件 2021.09.16
- 【vi/vim】基本使用及命令汇总
- AcWing 605. Simple product (implemented in C language)
- 【北京航空航天大学】考研初试复试资料分享
- Remote login sshd service
- IO stream of file and Base64
- [sciter]: how sciter uses i18 to realize multi language switching of desktop applications and its advantages and disadvantages
猜你喜欢

Leetcode 48. 旋转图像(可以,已解决)

RemoteViews布局和类型限制源码分析

Chendanqi, Fang Fei, guquanquan and Li Bo won the prize, and the list of Sloan research award in 2022 was released

JS foundation 8

How to deploy the software testing environment?

Day33 JS note event (Part 2) September 28, 2021
Three ways to implement LRU cache (recommended Collection)

Simulation of the Saier lottery to seek expectation

What method is required for word, PDF and txt files to realize full-text content retrieval?

Swin, three degrees! Eth open source VRT: a transformer that refreshes multi domain indicators of video restoration
随机推荐
【JS】斐波那契数列实现(递归与循环)
【C语言】如何很好的实现复数类型
JS foundation 8
PrecomputedTextCompat用法及原理
AcWing 609. Salary (implemented in C language)
Web3安全连载(3) | 深入揭秘NFT钓鱼流程及防范技巧
Daily practice of C language - day 3: calculate the number of occurrences of sub strings of strings
SEO优化的许多好处是与流量有直接关系
.NET混合开发解决方案24 WebView2对比CefSharp的超强优势
案例驱动 :从入门到掌握Shell编程详细指南
水果FL Studio/Cubase/Studio one音乐宿主软件对比
Open3d manual clipping point cloud
day32 js笔记 事件(上)2021.09.27
Random forest and poetry maker trained by AMR
If you want to change to software testing, how can you package your resume as a test engineer with 1 year of work experience
Leetcode 705. 设计哈希集合
6. calculation index
AcWing 604. Area of circle (implemented in C language)
Solutions to connection failures and errors when accessing mysql8 using the SSM project
cdc同步 如果数据库表的主键发生了变化,会同步成两个数据 还是会同步更新主键呢?