我收到此错误:
07-21 11:05:21.484: E/AndroidRuntime(1329):
java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
07-21 11:05:21.484: E/AndroidRuntime(1329):
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
我该如何处理这种错误?这是我的代码:
try {
List<Address> addresses = mGeocoder.getFromLocation(gettextLat, gettextLong, 1);
Log.e("TAG", addresses.get(0).getAddressLine(0) +
addresses.get(0).getAddressLine(1) +
addresses.get(0).getAddressLine(2));
String myAddress = addresses.get(0).getAddressLine(0) +
addresses.get(0).getAddressLine(1) + addresses.get(0).getAddressLine(2);
textAddresss.setText(myAddress);
} catch (IOException e) {
e.printStackTrace();
}