实现一个activity中传输信息到另一个activity
2017-03-19 10:45
176 查看
android开发中经常需要处理各种各样不同的信息,而不同activity中发送和接收信息对于开发也是相当重要的。
方法一:
发送方代码:
Intent intent = new Intent(MainActivity.this,SecondActivity.class); Bundle bundle=new Bundle();
bundle.putInt("position", position);
intent.putExtras(bundle);
startActivity(intent);
接收方代码:
Bundle bundle = getIntent().getExtras();//获取从mainactivity中传过来的对象
int position = bundle.getInt("position");//根据设定的键值获取对应的信息
方法二:
发送方:
Intent intent = new Intent(MainActivity.this,SecondActivity.class);
intent.putExtra("position", position);
intent.putExtra("name", name);
startActivity(intent);
接收方:
Intent intent = getIntent();
int position = intent.getIntExtra("position", 0);
String name = intent.getStringExtra("name");
接收到的内容就可以直接利用
本文出自 “11828641” 博客,请务必保留此出处http://11838641.blog.51cto.com/11828641/1842683
方法一:
发送方代码:
Intent intent = new Intent(MainActivity.this,SecondActivity.class); Bundle bundle=new Bundle();
bundle.putInt("position", position);
intent.putExtras(bundle);
startActivity(intent);
接收方代码:
Bundle bundle = getIntent().getExtras();//获取从mainactivity中传过来的对象
int position = bundle.getInt("position");//根据设定的键值获取对应的信息
方法二:
发送方:
Intent intent = new Intent(MainActivity.this,SecondActivity.class);
intent.putExtra("position", position);
intent.putExtra("name", name);
startActivity(intent);
接收方:
Intent intent = getIntent();
int position = intent.getIntExtra("position", 0);
String name = intent.getStringExtra("name");
接收到的内容就可以直接利用
本文出自 “11828641” 博客,请务必保留此出处http://11838641.blog.51cto.com/11828641/1842683
相关文章推荐
- 实现一个activity中传输信息到另一个activity
- 如何实现当一个应用调用另一个应用的某个activity的时候,让这个activity类似dialog的效果,但是这个应用单独运行的时候还是铺满屏幕的效果
- Java代码之JDBC实现数据库之间定时的表格传输(由一个库读取到另一个库)实例
- 三种方式实现在一个Activity中控制另一个Activity的UI的更新
- java--socket实现一个客户端像另一个客户端发送信息
- Android开发笔记---如何添加一个新的activity并实现一个activity到另一个activity的转换以及关闭自身
- 在实现了slidingmenu的MainActivity中添加一个Button实现主activity到另一个activity的跳转,程序无法运行
- android开发,如何实现通过上拉由一个activity切换到另一个activity
- 分布式编程->Remoting的一个代码示例(借助Remoting实现发送信息功能)
- 在一个窗体下实现另一个窗体内容的更新
- 实现一个压缩Remoting传输数据的Sink:CompressionSink (转载)
- 通过AEC解读WF的核心原理(七)一个实现Goto功能的Activity
- [转]Remoting的一个代码示例(借助Remoting实现发送信息功能)
- 分布式编程->Remoting的一个代码示例(借助Remoting实现发送信息功能)
- 实现一个压缩Remoting传输数据的Sink:CompressionSink (转载)
- 一个大学C语言试题的简单实现--员工信息管理程序
- 分布式编程->Remoting的一个代码示例(借助Remoting实现发送信息功能)
- SQL server 2000 编写cursor,实现从另一个表中读取数据到一个表中。
- 在一个页面中用脚本实现对另一个页面的刷新
- 一个openlaszlo使用flash的共享对象实现保存客户端信息的例子