android,可以进入另一个layout和activity,但无法返回上一个layout和上一个activity,怎么解决?
本人新手,望各位不吝赐教!我觉得都应该是一个道理,但不知是哪里错了,就是不能返回下面是可以进入另一个activity的代码:publicclasscativity_one...
本人新手,望各位不吝赐教!
我觉得都应该是一个道理,但不知是哪里错了,就是不能返回
下面是可以进入另一个activity的代码:
public class cativity_one extends Activity {
/** Called when the activity is first created. */
private TextView mTextView01;
private Button mButton01;
private Button mButton02;
//省略onCreate部分代码
mButton02.setOnClickListener( new Button.OnClickListener() {
@Override
public void onClick(View v) {
//mTextView01.setText("你又点了一次");
Intent intent=new Intent();
intent.setClass(cativity_one.this, register.class);
startActivity(intent);
//cativity.this.finish();
}
});
}
下面是不能返回的代码:
public class register extends Activity {
@Override
public void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout3);
Button b1=(Button) findViewById(R.id.myButton06);
b1.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
Intent intent=new Intent();
intent.setClass(register.this, cativity_one.class);
startActivity(intent);
//register.this.finish();
}
});
}
} 展开
我觉得都应该是一个道理,但不知是哪里错了,就是不能返回
下面是可以进入另一个activity的代码:
public class cativity_one extends Activity {
/** Called when the activity is first created. */
private TextView mTextView01;
private Button mButton01;
private Button mButton02;
//省略onCreate部分代码
mButton02.setOnClickListener( new Button.OnClickListener() {
@Override
public void onClick(View v) {
//mTextView01.setText("你又点了一次");
Intent intent=new Intent();
intent.setClass(cativity_one.this, register.class);
startActivity(intent);
//cativity.this.finish();
}
});
}
下面是不能返回的代码:
public class register extends Activity {
@Override
public void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout3);
Button b1=(Button) findViewById(R.id.myButton06);
b1.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
Intent intent=new Intent();
intent.setClass(register.this, cativity_one.class);
startActivity(intent);
//register.this.finish();
}
});
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询