且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从一个活动将值传递给另一个机器人?

更新时间:2023-08-27 09:57:34

您可以使用捆绑在Android的做同样的

You can use Bundle to do the same in Android

创建的意图:

Intent i = new Intent(this, ActivityTwo.class);
AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.autocomplete);
String getrec=textView.getText().toString();

//Create the bundle
Bundle bundle = new Bundle();

//Add your data to bundle
bundle.putString("stuff", getrec);

//Add the bundle to the intent
i.putExtras(bundle);

//Fire that second activity
startActivity(i);

现在你的第二个活动从包中检索数据:

Now in your second activity retrieve your data from the bundle:

//Get the bundle
Bundle bundle = getIntent().getExtras();

//Extract the data…
String stuff = bundle.getString("stuff");