实现了Android的关键字 [英] Implements keyword in android

查看:113
本文介绍了实现了Android的关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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

和浏览这里实现:<一href="http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/2.1_r2/android/view/View.java" rel="nofollow">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

这篇关于实现了Android的关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆