在oneActivity中实现跳转到MainActivity

       //intent 用来跳转另外一个MainActivity,bundle传值到MainActivity
         Intent MainActivity = new Intent();
         MainActivity .setClass(this,MainActivity.class);
         Bundle bundle = new Bundle(); //该类用作携带数据   
         bundle.putString("user", user.getText().toString());
         MainActivity.putExtras(bundle);  //向MainActivity传值
         this.startActivity(MainActivity);

         qq463431476

       在MainActivity需要跳转Fragment,

       Fragment获取 oneActivity里面的值:

 

         //接收 user的值
         Bundle bundle=getActivity().getIntent().getExtras();   
         String user=bundle.getString("user");

 

个人研究得出。

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-19
  • 2022-12-23
  • 2021-11-29
  • 2021-09-02
  • 2022-12-23
  • 2021-12-18
相关资源
相似解决方案