页面之间的跳转是在两个activity之间的跳转
每个activity都有与之对应的xml文件
activity2-托管按钮的活动
package com.example.genius.activity_02;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Activity_02 extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_02);
Button myButton = null;
myButton = (Button)findViewById(R.id.myButton);
myButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent();
intent.setClass(Activity_02.this, OtherActivity.class);
Activity_02.this.startActivity(intent);
}
});
}
}
被跳转的页面
package com.example.genius.activity_02;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class OtherActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.other);
TextView myTextView = null;
myTextView = (TextView)findViewById(R.id.myTextView);
myTextView.setText("跳转成功!");
}
}
遇到的一些问题
不知道什么原因,这样程序是无法运行的虽然没有报错但是
最后无法跳转页面,但是之后在manifest文件里面声明了新加入的activity之后就正常跳转了