ImageView をクリックするたびに、onclick メソッドが発生しません。私のmain.xmlにリダイレクトしていないということです
// パッケージ名 : bunk
//私の cesem.XML :
// Textview と Image View のみ - 4 つのスペースをインデントします。
<?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:padding="25dp"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Select Your Semester"
android:textSize="25dp"
android:gravity="center"
android:id="@+id/tvSemCe"
android:layout_marginBottom="20dp"
/>
<ImageView
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/back"
/>
</LinearLayout>
//Class file: Cesem.java
package com.bunk;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
public class Cesem extends Activity implements OnClickListener{
ImageView back;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.cesem); // cesem.xml
back=(ImageView) findViewById(R.id.back);// back is ImageView
back.setOnClickListener(this);
}
public void onClick(View v) {
// TODO Auto-generated method stub
if (v == back) {
setContentView(R.layout.main);
}
}
}