我的Android應用程序出現問題。我有三個活動,全部通過圖像按鈕相互連接。無法返回按鈕
我的問題是我不能回去的任何頁面,只是轉發。我一直在閱讀關於後退按鈕以及如何保持其狀態並且不殺死(結束)它,所以用戶可以在需要時點擊回來。
我是Android新手,我知道有很多東西需要學習。所以謝謝你的幫助。針對第一個活動
Java代碼:
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() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(NewhopeActivity.this, Act2.class);
startActivity(intent);
}
});
}
}
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" android:background="@drawable/mint">
<ImageButton
android:id="@+id/imagebutton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="250dp"
android:background="@drawable/ic_launcher"
android:onClick="Act2"
android:src="@drawable/ic_launcher" />
</LinearLayout>
告訴我們您的Manifest.xml – 2012-02-04 15:49:15
你可以上傳你的清單文件。我可以」沒有看到你的代碼有任何問題。後退按鈕應該起作用,因爲您只是從兒童活動回到父活動。 – 2012-02-04 15:50:35
android:onClick \t \t當視圖被點擊時,在這個視圖的上下文中調用方法的名稱。 – L7ColWinters 2012-02-04 15:50:36