当前位置: 代码迷 >> Android >> 怎么将textView中的数据封装到bean中传给另一个activity,并解析出
  详细解决方案

怎么将textView中的数据封装到bean中传给另一个activity,并解析出

热度:74   发布时间:2016-04-28 06:07:08.0
如何将textView中的数据封装到bean中传给另一个activity,并解析出
主activity是一个二级列表,点击子表中一项将其封装为bean传给下一个acvitvty
------解决方案--------------------
//使用Bundle传递数据参数
Intent intent=new Intent();
intent.setClass(MainActivity.this, TwoActivity.class);
Bundle bundle=new Bundle();
bundle.putString("name", "你好");
bundle.putString("pwd", “123”);
intent.putExtras(bundle);
startActivity(intent);
另一个activity取值:
Bundle bundle=this.getIntent().getExtras();
String strName=bundle.getString("name");
String strPwd=bundle.getString("pwd");
txtTitle.setText("欢迎:"+strName+" pwd:"+strPwd);
  相关解决方案