English 中文(简体)
更改语
原标题:AdapterView Anonymous Object

I m new to java and android. i don t understand this code

    gridview.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            Toast.makeText(HelloGridView.this, "" + position, Toast.LENGTH_SHORT).show();
        }
    }); 

this s my guess : OnItemClickListener is an interface. we create an anonymous object from the class AdapterView. i got information that AdapterView.OnItemClickListener is an interface from AdapterView.OnItemClickListener

是正确的?

最佳回答

从根本上说,这一机制使你能够确定在事件发生时可以操作的一套法典。 在本案中,该事件是GridView的射线。 甲型六氯环己烷的使用方式相当普遍。 无论你想要做什么,你都超越了接口方法,在采取行动时,该系统将叫他们。

我鼓励你在安森斯探讨这种模式的一些更为常见的例子。 看一看 j子,特别是<条码>公共真空板 On{ACTION}Listener( 有许多可能的行动,点击和点击是两个共同的行动。

rel=“nofollow”>android.wiget 。 最高层附近有一大批接口。 其中几个是名单接口,与此类似。

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签