我正在尝试从第二个 Activity 的列表中获取总消息值。我已经实现了这个。但如果是字符串,它总是显示 0 或 null 值。谁能告诉我如何在第一个 Activity 中获取 ArrayList 大小。
我的代码是,
在第二个 Activity 中:
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
我的第一个 Activity 是,
String size=InboxActivity.msgcount;
System.out.println("count:::::::::::::"+size);//it prints 0
谁能告诉我如何获取第一个 Activity 中的列表计数?
最佳答案
使列表静态并创建静态 get 方法。
关于java - 从第二个 Activity 获取第一个 Activity 中的列表计数值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20114627/