【发布时间】:2013-12-05 13:10:06
【问题描述】:
我正在尝试从第二个 Activity 的列表中获取总消息值。我已经实现了这一点。但在 String 的情况下,它总是显示 0 或 null 的值。谁能告诉我如何在我的第一个 Activity 中获得 ArrayList 的大小。
我的代码是,
在第二个活动中:
private static List<String> msgList = new ArrayList<String>();//above oncreate method
setMsgList(getSMS());//call the method
int count = getMsgList().size();
msgcount = String.valueOf(count);
System.out.println("listcount" + msgcount);//it prints the correct list size
我的第一个活动是,
String size=InboxActivity.msgcount;
System.out.println("count:::::::::::::"+size);//it prints 0
谁能告诉我如何在第一个 Activity 中获取列表计数?
【问题讨论】:
-
你的 msgcount 是不是公开的???
-
msgcount 不应该是公开的,更不应该是静态的。请参阅我的答案以获得解决方案。
标签: java android list android-activity count