当前位置:网站首页>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();
}
}
}
}边栏推荐
- Pre parsing, recursive functions and events in day25 JS 2021.09.16
- Is it safe to buy stocks and open an account on the account QR code of the CICC securities manager? Ask the great God for help
- Day28 strict mode, string JS 2021.09.22
- 2. single digit statistics
- Open3d manual clipping point cloud
- Day39 prototype chain and page fireworks effect 2021.10.13
- Contract quantification system development (construction explanation) - contract quantification system development (source code analysis and ready-made cases)
- Come on, yuanuniverse. Sure enough, the heat won't pass for a while
- Simulation of the Saier lottery to seek expectation
- 如何获取泛型的类型
猜你喜欢

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

开源项目维权成功案例: spug 开源运维平台成功维权

If you want to change to software testing, how can you package your resume as a test engineer with 1 year of work experience

Day34 JS notes regular expression 2021.09.29

How to deploy the software testing environment?

Unity screenshot function

Graphics view framework for QT learning (to realize startup animation)

Simulation of the Saier lottery to seek expectation

Using soapUI to obtain freemaker's FTL file template

Multi dimensional monitoring: the data base of intelligent monitoring
随机推荐
AcWing 610. Salary and bonus (implemented in C language)
Fruit FL studio/cubase/studio one music host software comparison
Oracle date format exception: invalid number
NFT card chain game system development DAPP construction technical details
ArrayList源码解析
Many benefits of SEO optimization are directly related to traffic
Why do many people want to change careers as programmers, while some programmers want to change careers as others?
Cohere, a large model company, completed the round B financing of US $125million
AcWing 606. Average 1 (implemented in C language)
ProCAST finite element casting process simulation software
Prefix and (one dimension)
Pre parsing, recursive functions and events in day25 JS 2021.09.16
day24 js笔记 2021.09.15
Research on personalized product search
Unity screenshot function
RemoteViews布局和类型限制源码分析
纯纯大怨种!那些年被劝退的考研专业
Day37 JS note motion function 2021.10.11
Redis hash hash type string (5)
The development and principle of the metacosmic system