在我的android应用程序中,有3个活动。当我点击第一个屏幕上的一个按钮时,它会进入第二个屏幕,点击第二个屏幕上的一个按钮,它应该进入第三个屏幕。但是,当我点击第二个屏幕上的按钮时,它会进入第一个屏幕。我不知道我的代码中存在什么问题。我如何从第二次活动到第三次?
这是CatalogueActivity
:
package com.Catalogue;
import android.app.Activity;
import android.view.View.OnClickListener;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.content.Intent;
public class CatalogueActivity extends Activity {
private Button button;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.button = (Button) this.findViewById(R.id.rdb8);
this.button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setClass(CatalogueActivity.this, familyevent.class);
startActivity(intent);
}
});
}
}
这是familyevent
活动:
package com.Catalogue;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class familyevent extends Activity {
private Button button;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.familyevent);
this.button = (Button) this.findViewById(R.id.r1);
this.button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setClass(familyevent.this, info.class);
startActivity(intent);
}
});
}
}
这是info
活动:
package com.Catalogue;
import android.app.Activity;
import android.os.Bundle;
public class info extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.info);
}
}
是你看到在logcat的东西吗?一些例外?如果是的话,你也可以把它放在这里。 – havexz
是的,有些logcat输出会帮助更多 – Manos
我明白为什么我们的大脑在没有日志猫的情况下出现错误问题时响起,但在这种情况下,绝对不需要日志猫,因为没有任何错误首先(就编译器而言,逻辑完全是另一个问题)。他有一个代码逻辑问题,而不是一个错误。 – davidcesarino