我的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