gpt4 book ai didi

java.lang.IndexOutOfBoundsException : Invalid index 1, 大小为 1

转载 作者:太空狗 更新时间:2023-10-29 16:20:45 45 4
gpt4 key购买 nike

<分区>

我必须开发一个 Android 应用程序。在这里我收到以下错误:

03-26 21:29:00.394: E/AndroidRuntime(684): FATAL EXCEPTION: main
03-26 21:29:00.394: E/AndroidRuntime(684): java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1
03-26 21:29:00.394: E/AndroidRuntime(684): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)
03-26 21:29:00.394: E/AndroidRuntime(684): at java.util.ArrayList.get(ArrayList.java:311)
03-26 21:29:00.394: E/AndroidRuntime(684): at com.xmlparsing.MainActivity.loadXMLData(MainActivity.java:303)
03-26 21:29:00.394: E/AndroidRuntime(684): at com.xmlparsing.MainActivity.access$2(MainActivity.java:118)
03-26 21:29:00.394: E/AndroidRuntime(684): at com.xmlparsing.MainActivity$GetXmlFiles.onPostExecute(MainActivity.java:369)
03-26 21:29:00.394: E/AndroidRuntime(684): at com.xmlparsing.MainActivity$GetXmlFiles.onPostExecute(MainActivity.java:1)
03-26 21:29:00.394: E/AndroidRuntime(684): at android.os.AsyncTask.finish(AsyncTask.java:417)
03-26 21:29:00.394: E/AndroidRuntime(684): at android.os.AsyncTask.access$300(AsyncTask.java:127)
03-26 21:29:00.394: E/AndroidRuntime(684): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
03-26 21:29:00.394: E/AndroidRuntime(684): at android.os.Handler.dispatchMessage(Handler.java:99)
03-26 21:29:00.394: E/AndroidRuntime(684): at android.os.Looper.loop(Looper.java:123)
03-26 21:29:00.394: E/AndroidRuntime(684): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-26 21:29:00.394: E/AndroidRuntime(684): at java.lang.reflect.Method.invokeNative(Native Method)
03-26 21:29:00.394: E/AndroidRuntime(684): at java.lang.reflect.Method.invoke(Method.java:521)
03-26 21:29:00.394: E/AndroidRuntime(684): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-26 21:29:00.394: E/AndroidRuntime(684): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-26 21:29:00.394: E/AndroidRuntime(684): at dalvik.system.NativeStart.main(Native Method)

这里我使用了下面的代码:

String[] stockArrVideo = new String[Appscontent.Sub_arraylistvideo.size()];
stockArrVideo = Appscontent.Sub_arraylistvideo.toArray(stockArrVideo);
for (String s : stockArrVideo) {
if (s.startsWith(number)) {
String _Substring;
_Substring = s.substring(1);
if(_Substring.equals("")||_Substring == null) {
_Substring = "No Records";
}
Appscontent.Sub_arraylistvideosub.add(_Substring);
}
h++;
}

如果数据为空,则表示我必须显示“无记录”消息。否则显示正确的数据。

TextView mVideo = new TextView(this); 
System.out.println(Appscontent.Sub_arraylistvideosub.get(j));
mVideo.setText(Appscontent.Sub_arraylistvideosub.get(j));
mVideo.setLayoutParams(textLayoutParams);
mVideo.setBackgroundColor(Color.BLACK);

这里我写了检查空数据的代码。

是什么导致了这个异常?

45 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com