长时间的Android用户第一次开发人员。我试图简单地设置我的应用程序的第一个动作,它是两个按钮,一个将打开浏览器并将用户发送到URL,另一个将打开从URL获取XML数据并显示一个节点的值的页面。卡住的第一个简单的Android应用程序
但现在我只是想知道为什么我收到以下错误:
Description Resource Path Location Type
The type new View.OnClickListener(){} must implement the inherited abstract method View.OnClickListener.onClick(View) patriosar.java /com.patriotsar/src/com/patriotsar line 27 Java Problem
JAVA:
package com.patriotsar;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.widget.Button;
import android.widget.TextView;
public class patriosar extends Activity {
private Button startButton;
private Button subscribe;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.findAllViewsById();
startButton.setOnClickListener(new OnClickListener() {
});
subscribe.setOnClickListener(new OnClickListener() {
});
private void findAllViewsById() {
start = (Button) findViewById(R.id.startbutton);
subscribe = (Button) findViewById(R.id.subscribe);
}
}
}
main.xml中
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bgimage2">
>
<Button
android:id="@+id/startButton"
android:layout_width="150px"
android:layout_height="wrap_content"
android:text="@string/start"
android:layout_x="80px"
android:layout_y="21px"
>
</Button>
<Button
android:id="@+id/subscribe"
android:layout_width="150px"
android:layout_height="wrap_content"
android:text="@string/subscribe"
android:layout_x="80px"
android:layout_y="74px"
>
</Button>
<TextView
android:id="@+id/textview"
android:layout_width="300px"
android:layout_height="fill_parent"
android:text="@string/intro"
android:layout_y="300px"
android:layout_x="20px"
android:textColor="#ffffff"
/>
</AbsoluteLayout>
我知道它不做任何事,但不知道为什么我已经得到错误。任何帮助将是真棒
您是否熟悉事件侦听器和接口?您需要重写OnClickListeners的onClick()方法。 – Swapna 2011-05-28 06:52:35