哪裏有點擊ImageView onclick方法沒有hapenning。我的意思是不是重定向到我的main.xml我無法在Android設備上的Imageview上設置Onclick事件
//包名:雙層
//我cesem.XML:
//只是一個TextView和圖像查看 - 縮進四個空間。
<?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);
}
}
}
仍然沒有工作的弟弟.. :( – smitlife
不工作:(你可以請下載並檢查它嗎? docs.google.com/file/d/0B8kSGDgP5vndelVZRnJ0YUZ0U0k/ – smitlife
哎呀我的意思是這個鏈接 https://docs.google.com/file/d/0B8kSGDgP5vndelVZRnJ0YUZ0U0k/edit – smitlife