Android 实现界面(Activity)的跳转

界面跳转

如,我想重一个界面A跳转到界面B,可以用,setContentView(R.layout.activity_login); 但是他其实只是将改界面铺在了最顶层,而按menu这些菜单其实还是底层中的界面,要实现界面的跳转需要用如下方法:

Intent mIntent =  new Intent();
mIntent.setClass(Login.this, JF_Login.class);
startActivity(mIntent);

界面传值

要实现不同界面的传值就需要用到Android中的另一个对象,Bundle对象。

有关Bundle的简单介绍可以参考:

http://blog.csdn.net/randyjiawenjie/article/details/6651437

在传递的源界面增加如下代码

Intent mIntent =  new Intent();
mIntent.setClass(Login.this, JF_Login.class);
Bundle bundle = new Bundle();
bundle.putString("MyAccout", "297018758");
mIntent.putExtras(bundle);
startActivity(mIntent);         

只需要在目录的onCreate方法中增加如下代码:

        Bundle myBundle = getIntent().getExtras();
        String myAccount = myBundle.getString("MyAccout");
原文地址:https://www.cnblogs.com/jiguixin/p/3184443.html