我怎样才能从第二个活动转到第三个活动?
在我的 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);
}
}
In my android app, there are 3 activities. When I click a button on the first screen, it goes to second screen, click a button on the 2nd screen, it should go to the third. However, when I click the button on 2nd screen, it goes to the 1st screen. I don't know what is the problem in my code.
This is the 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);
}
});
}
}
This is the familyevent
activity:
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);
}
});
}
}
This is the info
activity:
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);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
分别尝试
和
。
Try the
and
respectivly.
您可以尝试以下操作:
来自 CatalogueActivity:
和来自 familyevent:
希望这有效。
You can try this:
From CatalogueActivity:
and from familyevent:
hope this works.
试试这个:
try this: