你如何传递数据/参数到Android的另一个活动 [英] How do you pass data/parameters to another activity in Android

查看:159
本文介绍了你如何传递数据/参数到Android的另一个活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将数据/参数值传递从一个活动到另一个机器人?

How to pass data/parameter values from one activity to another in android?

我已经用

loginname=txtloginname.getText().toString();
password=txtpassword.getText().toString();
Bundle bundle = new Bundle();
bundle.putString("loginname", loginname);
bundle.putString("password", password);
Intent newIntent=new Intent();
newIntent.putExtras(bundle);
setResult(RESULT_OK,newIntent);
finish();

但我只能得到登录名值如何将登录和密码键和值?

But I can only get loginname value How to put both login and password key and value?

推荐答案

您可以只是说 newIntent.putExtra(名,值); 用它多次添加多个数据。并根据这些数据,您储存来电 getStringExtra(姓名); 在接下来的活动

You can just say newIntent.putExtra("name",value); use it multiple times to add multiple data. And depending on the data you stored call getStringExtra("name"); in the next activity.

这篇关于你如何传递数据/参数到Android的另一个活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆