本文介绍了什么是<?>意味着在Android方法签名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  public void onItemClick(AdapterView<?>父,View v,int position,long id)

<

谢谢。

解决方案

/ div>

AdapterView 是一个泛型类。它以另一种数据类型作为参数,然后以某种方式将其操作定制为该类型。通常,您将声明一个 AdapterView 类似于

  AdapterView< String> ; avs = new AdapterView< String>(...); 

这指的是一个 AdapterView code> String s。



现在,给出所有这些:<?> code>表示这个方法将接受一个 AdapterView ,而不管它被定制的类。这是一个通配符类型说明符。


I 'm going through a code and found the following method declaration.

public void onItemClick(AdapterView<?> parent, View v, int position, long id)

What does <?> mean here?

Thank you.

解决方案

AdapterView is a generic class. It takes another data type as a parameter, and its operation is then customized towards that type, in a way. Normally, you'll declare an AdapterView something like

AdapterView<String> avs = new AdapterView<String>(...);

This refers to an AdapterView customized for Strings.

Now, given all that: the <?> means that this method will accept an AdapterView regardless of the class it's customized for. It's a wildcard type specifier.

这篇关于什么是&lt;?&gt;意味着在Android方法签名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 21:37