显示调用:
第一个Activity
public class MainActivity extends AppCompatActivity {
//跳转按钮
Button but_login;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
but_login = findViewById(R.id.but_login);
//设置点击事件
but_login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//这里启动下一个活动
Intent intent = new Intent(MainActivity.this,Home.class);
startActivity(intent);
}
}
}
}
第二个Activity
public class Home extends Activity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_yingyingying);
}
}
关键代码就两句:
/**
*Intent intent = new Intent(当前类名.this,需要启动的类名.class);
*/
Intent intent = new Intent(MainActivity.this,Home.class);
startActivity(intent);