实现了Android的关键字实现了、关键字、Android

2023-09-04 06:11:50 作者:岁月的吻痕

在Android的我看到了code是这样的:

In Android I am seeing code like this:

public class Now extends Activity implements View.OnClickListener

这是合法的java吗?到底是什么View.OnClickListener重新$ P $这里psenting。

Is this legal in java? What exactly is View.OnClickListener representing here.

推荐答案

OnClickListener 是用来接收click事件的接口。你需要重写的onClick()方法和实现自己的code来对付它。 http://developer.android.com/reference/android/view/View .OnClickListener.html

OnClickListener is the interface used to receive click events. You need to override the onClick() method and implement your own code to deal with it. http://developer.android.com/reference/android/view/View.OnClickListener.html

您可以看看在查看阶级结构此处的 http://developer.android.com/reference/android/view/View.html#nestedclasses

You can take a look at the View class structure here: http://developer.android.com/reference/android/view/View.html#nestedclasses

和浏览这里实现:http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/2.1_r2/android/view/View.java

您可能需要阅读的Andr​​oid开发人员指南(特别是主题,以处理UI事件)的 http://developer.android.com/guide/topics/ui/ui-events.html

You may want to read the android Dev Guide (specially the topic to handle UI events): http://developer.android.com/guide/topics/ui/ui-events.html

下面的两个是等效的:

import android.view.View;
public class Now extends ActivityGroup implements OnClickListener {

import android.view.*;
public class Now extends ActivityGroup implements View.OnClickListener {

澄清后不需要以下

The following are not needed after the clarification

也许是甲骨文的Java接口教程:

And perhaps the Oracle's java interface tutorial:

http://download.oracle.com/javase/tutorial/爪哇/概念/ interface.html

http://download.oracle.com/javase/tutorial/爪哇/ IandI / createinterface.html