mActivity.runOnUiThread(() -> { if (limitInfo != null) { for (int i = 0; i < limitInfo.size(); i++) { String[] arr = limitInfo.get(i).split(","); Log.e(TAG, "第" + arr[0] + "条路线限行消息:" + arr[1]); } } if (mRoutePlanItems != null) { if (mRoutePlanItems.size() > 0 && mRoutePlanItems.get(0) != null) { initTabView(mLayoutTab0, mRoutePlanItems.get(0)); } if (mRoutePlanItems.size() > 1 && mRoutePlanItems.get(1) != null) { initTabView(mLayoutTab1, mRoutePlanItems.get(1)); mLayoutTab1.setVisibility(View.VISIBLE); } else { mLayoutTab1.setVisibility(View.GONE); } if (mRoutePlanItems.size() > 2 && mRoutePlanItems.get(2) != null) { initTabView(mLayoutTab2, mRoutePlanItems.get(2)); mLayoutTab2.setVisibility(View.VISIBLE); } else { mLayoutTab2.setVisibility(View.GONE); } } mLayoutTab0.setSelected(true); mRouteList.clear(); mRouteList.addAll(mRouteDetails.get(0)); LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity()); mRecyclerView.setLayoutManager(layoutManager); mResultAdapter = new RouteResultAdapter(mRouteList); mRecyclerView.setAdapter(mResultAdapter); // 展示长途信息 if (BaiduNaviManagerFactory.getRouteResultManager().isLongDistance()) { mLDLayout.setVisibility(View.VISIBLE); } else { mLDLayout.setVisibility(View.GONE); } }); 报错 java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
时间: 2024-03-19 12:42:46 浏览: 114
wait-timer:从 code.google.compwait-timer 自动导出
这段代码中可能会出现 java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 异常,这是因为在访问 mRouteDetails 的时候,mRouteDetails 是一个空的列表,而你尝试访问其第一个元素。可以在使用 mRouteDetails 前先判断其是否为空,或者在使用前先对其进行初始化。
阅读全文