从一个活动传递一个字符串到Android的另一个活动 [英] Pass a String from one Activity to another Activity in Android

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

问题描述

这是我的字符串:

private final String easyPuzzle ="630208010200050089109060030"+
                                 "008006050000187000060500900"+
                                 "09007010681002000502003097";

我想给这个字符串就在9 * 9的数独板的另一个活动。

I want to show this string on the another activity at the 9*9 sudoku board.

推荐答案

您需要把它作为一个额外的:

You need to pass it as an extra:

String easyPuzzle  = "630208010200050089109060030"+
                     "008006050000187000060500900"+
                     "09007010681002000502003097";

Intent i = new Intent(this, ToClass.class);
i.putExtra("epuzzle", easyPuzzle);
startActivity(i); 

然后从你喜欢这个新的活动将其解压缩:

Then extract it from your new activity like this:

Intent intent = getIntent();
String easyPuzzle = intent.getExtras().getString("epuzzle");

这篇关于从一个活动传递一个字符串到Android的另一个活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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