我正在将价值从传递Activity A
给Activity B
。它工作正常。
例如,如果我传递String "Harvey Brown"
,那么在下一个活动中它也会显示"Harvey Brown"
。
但我也想在"Author: "
之前添加文本,"Harvey Brown"
并TextView
以现在而不是仅显示总和结果"Harvey Brown"
。
它会显示
Author:Harvey Brown
为每一个意图。
这是代码,我用来传递字符串值:
intent.putExtra("Title",mData.get(position).getTitle());
在下一个活动中,我通过
Intent intent = getIntent();
String author_name = intent.getExtras().getString("author_name");
我相应地将值设置为
author_name = (TextView) findViewById(R.id.author_nameid);
author_name.setText(author_name);
您可以添加“作者:”前缀,如下所示-
author_name = (TextView) findViewById(R.id.author_nameid);
author_name.setText("Author: " + author_name);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句