【问题标题】:Reading String[] in another activity for SimpleAdapter在 SimpleAdapter 的另一个活动中读取 String[]
【发布时间】:2012-02-26 03:05:21
【问题描述】:

我在 Activity 中有一个名为 getData() 的方法,它返回一个 String[]:

例子:

public class Strings{
    public String[] getData(){
    String[] data = {"one","two","three"};
    return data;
    }
}

我的问题是如何检索这些项目,因为在另一个活动中,我想将其放入 SimpleAdapter 列表中。我可以打电话

String[] data = Strings.getData();

然后将它作为一个变量,在技术上是数组,但我需要将这些项目读出到适配器中。我知道这可能很简单,但就像我说的,菜鸟,哈哈。

【问题讨论】:

标签: android string arrays


【解决方案1】:

为了在不同 Activity 之间共享数据,我认为您需要在更改 Activity 之前使用 Intent 发送该数据

intent.putExtra("TheStrings", this.getStrings());

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多