Может кто-нибудь сказать мне, где я иду не так.У меня есть три вида деятельности, к которым я хочу подключиться.Этот код - мой первый файл Java и первый файл XML.я думаю, что мой код onclick где-то не так.мой конечный результат заключается в том, что все 3 действия связаны с 3 кнопками изображений ... спасибо
java 1.code package my.hope;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.content.Intent;
public class NewhopeActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView myImage = (ImageView) findViewById(R.id.imageButton1);
myImage.setOnClickListener(new OnClickListener() {
intent intent = new intent(Newhopeactivity.this, Act2.class);
startActivity(intent);
public void onClick(View v) {
// TODO Auto-generated method stub
}
}
);
}
}
xml.код
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/bt" />
<ImageButton
android:id="@id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
android:onClick="Act2"/>