Android 我无法从列表中提取对象?当我尝试将它存储到另一个对象时,会得到一个空值
Log.d不起作用,因为logcat中没有打印任何值Android 我无法从列表中提取对象?当我尝试将它存储到另一个对象时,会得到一个空值,android,android-listview,Android,Android Listview,Log.d不起作用,因为logcat中没有打印任何值 我认为可能有问题,因为if语句中的内容可能无法访问我立即发现这两行有问题 protected void onPostExecute(ArrayList<Container> result) { if (exception != null) { showAlert("Error", exception.getMessage()); }
我认为可能有问题,因为if语句中的内容可能无法访问我立即发现这两行有问题
protected void onPostExecute(ArrayList<Container> result) {
if (exception != null) {
showAlert("Error", exception.getMessage());
}
ArrayList<Container> containerList = result;
containerNames = new String[containerList.size()];
containers = new Container[containerList.size()];
SharedPreferences myprefs = getSharedPreferences("myCustomSharedPrefs", Context.MODE_PRIVATE);
String containerName = myprefs.getString("name", null).trim();
if (containerList != null) {
for (int i = 0; i < containerList.size(); i++) {
Container container = containerList.get(i);
containers[i] = container;
containerNames[i] = container.getName().trim();
if(containerNames[i].equals(containerName))
{
abcd = containerList.get(i);
Log.d("value of abcd", abcd.getName());
}
}
}
//abcd = containers[2];
//setContainerList();
loading = false;
new LoadCDNContainersTask().execute((Void[]) null);
}
}
它们应该分别具有类型规范字符串[]和容器[]。我也不认为containerList有什么意义,因为它的结果是传入的,您可以访问它 您应该跟踪输入方法。您将知道异常的值。顺便说一下,java中还有一个调试器;你检查过containerName的值不为null吗?@TedHopp是的,我检查过它不为null。你检查过区分大小写吗?@Eden我检查过,但不起作用
containerNames = new String[containerList.size()];
containers = new Container[containerList.size()];