所以我有一个listview,它由一个存储在xml文件中的字符串数组填充。还有一个在同一个xml文件中具有相同长度的字符串数组。使用每个xml文件中的< 116个字符串,应用程序运行正常,但只要我向数组添加一个字符串项,应用程序崩溃,我就会收到以下错误。
11/21 16:13:00: Launching app
W/ResourceType: Failure getting entry for 0x010804ca (t=7 e=1226) (error -75)
W/ResourceType: Failure getting entry for 0x01080012 (t=7 e=18) (error -75)
Hot swapped changes, activity restarted
W/ResourceType: Failure getting entry for 0x7f0b003e (t=10 e=62) (error -75)
W/ResourceType: Failure getting entry for 0x7f020048 (t=1 e=72) (error -75)
W/ResourceType: Failure getting entry for 0x7f02004c (t=1 e=76) (error -75)
W/ResourceType: Failure getting entry for 0x7f02004a (t=1 e=74) (error -75)
W/ResourceType: Failure getting entry for 0x01080253 (t=7 e=595) (error -75)
W/ResourceType: Failure getting entry for 0x01080038 (t=7 e=56) (error -75)
W/ResourceType: Failure getting entry for 0x01080012 (t=7 e=18) (error -75)
W/ResourceType: Failure getting entry for 0x01080287 (t=7 e=647) (error -75)
W/ResourceType: Failure getting entry for 0x010803c0 (t=7 e=960) (error -75)
W/ResourceType: Failure getting entry for 0x010803bc (t=7 e=956) (error -75)
W/ResourceType: Failure getting entry for 0x010803de (t=7 e=990) (error -75)
W/ResourceType: Failure getting entry for 0x01080287 (t=7 e=647) (error -75)
W/ResourceType: Failure getting entry for 0x010805c9 (t=7 e=1481) (error -75)
W/ResourceType: Failure getting entry for 0x010804d5 (t=7 e=1237) (error -75)
W/ResourceType: Failure getting entry for 0x010804d5 (t=7 e=1237) (error -75)
W/ResourceType: Failure getting entry for 0x01080515 (t=7 e=1301) (error -75)
W/ResourceType: Failure getting entry for 0x01080027 (t=7 e=39) (error -75)
W/ResourceType: Failure getting entry for 0x010803e7 (t=7 e=999) (error -75)
W/ResourceType: Failure getting entry for 0x01080287 (t=7 e=647) (error -75)
W/ResourceType: Failure getting entry for 0x0108024f (t=7 e=591) (error -75)
W/ResourceType: Failure getting entry for 0x010803eb (t=7 e=1003) (error -75)
W/ResourceType: Failure getting entry for 0x010803c6 (t=7 e=966) (error -75)
W/ResourceType: Failure getting entry for 0x010803e3 (t=7 e=995) (error -75)
W/ResourceType: Failure getting entry for 0x01080096 (t=7 e=150) (error -75)
W/ResourceType: Failure getting entry for 0x01080342 (t=7 e=834) (error -75)
W/ResourceType: Failure getting entry for 0x01080346 (t=7 e=838) (error -75)
V/RenderScript: 0xa0831000 Launching thread(s), CPUs 4
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.zach.listview, PID: 953
java.lang.ArrayIndexOutOfBoundsException: length=690; index=690
at android.content.res.TypedArray.getResourceId(TypedArray.java:811)
at com.example.zach.listview.MainActivity$1.onItemClick(MainActivity.java:49)
at android.widget.AdapterView.performItemClick(AdapterView.java:310)
at android.widget.AbsListView.performItemClick(AbsListView.java:1145)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3066)
at android.widget.AbsListView$3.run(AbsListView.java:3903)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
申请已终止。
我环顾四周寻找答案,但我还没找到答案。任何帮助都会非常感激。
谢谢!
编辑:
继承我的mainactivity.java
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Action Bar customization
android.support.v7.app.ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayOptions(android.support.v7.app.ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setCustomView(R.layout.actionbar);
setContentView(R.layout.activity_main);
//fill list view with xml array of routes
final String[] values = getResources().getStringArray(R.array.routeList);
//fills route detail text view with xml array info
final String[] routeDetail= getResources().getStringArray(R.array.routeDetail);
//fills route detail image view with xml array of images
final TypedArray image = getResources().obtainTypedArray(R.array.routeImages);
//image.recycle();
//custom adapter for list view
ListAdapter routeAdapter = new CustomAdapter(this, values);
final ListView routeListView = (ListView) findViewById(R.id.routeListView);
routeListView.setAdapter(routeAdapter);
routeListView.setOnItemClickListener(
new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String route = values[position];
//for loop to increment through each route list item
int i;
for (i=0; i < values.length;i++)
{
int imageId = (int) image.getResourceId(i, -1);
if (route.equals(values[i]))
{
Intent intent = new Intent(view.getContext(), RouteDetails.class);
intent.putExtra("route", routeDetail[i]);
intent.putExtra("imageResourceId", imageId);
startActivity(intent);
}
}
}
}
);
}
}
和我的xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="routeList">
<item>Information</item>
<item>Crag Map</item>
<item>Main Wall</item>
<item>1. Shark Bait - 5.9</item>
<item>2. Rain Check - 5.8</item>
<item>3. Rain Check Direct - 5.8</item>
<item>4. Arocknophobia - 5.7</item>
<item>5. Balls Deep - 5.9+</item>
<item>6. Jingle Bells - 5.9</item>
<item>7. Itching to Climb - 5.8</item>
<item>8. Hog Nose 5.10+</item>
<item>9. Slab Dance - 5.10</item>
<item>10. Dont Screw With My Disco - 5.11c</item>
<item>11. Variation - Dont Faint On My Disco - 5.11c</item>
<item>12. Faint - 5.11d</item>
<item>13. Fracture - 5.11</item>
<item>14. Tap Dance - 5.10</item>
<item>15. Puss In Boots - 5.9+</item>
<item>16. Two Bolts No Balls - 5.9</item>
<item>17. Variation - Corny Alternate Start - 5.10</item>
<item>18. Corny (Dennys Route) - 5.9</item>
<item>19. Bye Bye Bolt - 5.9</item>
<item>20. Angry White Men - 5.11b</item>
<item>21. Monkey Boy - 5.12b</item>
<item>22. Monkey Girl - 5.9+</item>
<item>23. Variation - UCGB Slab Start - 5.10b/c</item>
<item>24. UCGB - 5.10b/c</item>
<item>25. The Sixth Element - 5.6</item>
<item>Orange Sunshine Wall</item>
<item>1. Sultans Of Swing - 5.6</item>
<item>2. Dirty Swing - 5.7</item>
<item>3. Dirty Thing - 5.9+/10</item>
<item>4. Orange Sunshine - 5.9</item>
<item>5. Jays - 5.10</item>
<item>6. Gym Dandy - 5.11c</item>
<item>7. Iodine-125 - 5.11a</item>
<item>8. Bottom Fishing - 5.9+</item>
<item>9. Bottom Feeder - 5.8+</item>
<item>10. Rocky And Bulwinkle - 5.5</item>
<item>Neophytes Wall</item>
<item>1. Coke And Hoes - 5.7</item>
<item>2. Super Lube - 5.7</item>
<item>3. Neophytes Delight - 5.6</item>
<item>4. Dancing Nancy - 5.7</item>
<item>5. Triple Boots Blithering Brisket - 5.9</item>
<item>6. Triple S - 5.4</item>
<item>7. Whimpering Wookiee - 5.7</item>
<item>8. Turkish Delight - 5.9</item>
<item>9. Matthews Climb - 5.6</item>
<item>10. Cheese Burger EC - 5.2</item>
<item>11. Connors Climb - 5.2</item>
<item>Zorro Wall</item>
<item>1. Bee Sting BeeStrong - 5.7</item>
<item>2. Red Skin - 5.9</item>
<item>3. Geronimo - 5.11</item>
<item>4. Got Choss - 5.7</item>
<item>5. Jengaistic - 5.8</item>
<item>6. Liken The Lichen - 5.8</item>
<item>7. Clown Shoes - 5.8+</item>
<item>8. Face O Meter - 5.10</item>
<item>9. Face Is Great - Choss Is Off - 5.8+</item>
<item>10. Zorro - 5.12a</item>
<item>11. Zorro Corner(Son Of Zorro) - 5.8+</item>
<item>12. Jenga - 5.9+</item>
<item>13. Pinch Six - 5.6</item>
<item>14. Slippery When Wet - 5.8+</item>
<item>Mid Wall</item>
<item>1. Crying Ryan - 5.9+</item>
<item>2. Click Click Boom - 5.12b</item>
<item>3. If By Left - 5.9</item>
<item>4. If By Right - 5.11c</item>
<item>Big Wall</item>
<item>1. CT7 - 5.11d</item>
<item>2. Romania - 5.14</item>
<item>3. Batman - 5.11</item>
<item>4. The Space Between - 5.11a</item>
<item>5. Laid Back And Well Hung - 5.11c</item>
<item>6. Twisted Sister - 5.11d</item>
<item>7. Groovin - 5.11d</item>
<item>8. Flippin The Bird - 5.13</item>
<item>9. Welcome To The Bird - 5.12b/c</item>
<item>10. Hinterland - 5.10b *2nd Pitch 5.12d</item>
<item>11. Opposing Gravity - 5.10 *2nd Pitch 5.13b/c</item>
<item>12. The Streak - 5.10 *2nd Pitch 5.13</item>
<item>13. Alpine Line - 5.9 *2nd Pitch 5.12d</item>
<item>14. Erics Project - 5.13</item>
<item>15. Broken Bit - 5.12</item>
<item>16. Wrecking Ball - 5.12</item>
<item>Lebowski Wall</item>
<item>1. The Dude Abides - 5.10</item>
<item>2. If You Will It, Its No Dream - 5.11</item>
<item>3. Nice Marmot - 5.11</item>
<item>4. Pretty Strict, UH, Drug Regimen - 5.8+</item>
<item>5. Shut Up Donny - 5.9</item>
<item>West Wall</item>
<item>1. Where The Wild Things Are - 5.10</item>
<item>2. Precarious - 5.10c</item>
<item>3. Spit On It - 5.10d</item>
<item>4. Crackalicious - 5.12c</item>
<item>5. Hot Pockets - 5.12b</item>
<item>Sun Wall</item>
<item>1. Uwe Come To America - 5.10+</item>
<item>2. The Virgin Suicides - 5.9+</item>
<item>3. Fear Re-Factored - 5.10+</item>
<item>4. Fear/Virgin Crossover - 5.9+</item>
<item>5. Smear Factor - 5.12c/d</item>
<item>6. Slime Factor - 5.10b</item>
<item>7. Pennsyltucky - 5.11b/c</item>
<item>8. Nine Line - 5.9</item>
<item>9. Will It Stay Or Will It Go - 5.10</item>
<item>10. Spiders And Snakes - 5.9+</item>
<item>11. Like A Slabby Virgin - 5.9</item>
<item>12. Slabtastic - 5.9+</item>
<item>13. High Steppin - 5.8</item>
<item>14. Ghetto Palm - 5.10+</item>
</string-array>
<string-array name="routeDetail">
<item>Information\n\nBirdsboro quarry is located in Birdsboro PA.\n\nDirections: To access the quarry park
in the dirt parking lot on haycreek road where it deadends. Use the cable bridge to cross the creek and
follow the old road until you come to a second cable bridge. Once across that follow the trail to
the left and then turn right and head towards the outhouse. Turn right at the outhouse and you will come
to the information board for the climbing area.\n\n To the right of the info board you will see a donation
box to fund bolting and maintenance for the climbing area. Donations are appreciated!\n</item>
<item>Crag Map\n\n This displays all the climbing areas and all of the routes in the quarry.\n\n\nClick
on image to enlarge and zoom</item>
<item>Overview of the Main Wall Climbing Area</item>
<item>1. Shark Bait - 5.9</item>
<item>2. Rain Check - 5.8</item>
<item>3. Rain Check Direct - 5.8</item>
<item>4. Arocknophobia - 5.7</item>
<item>5. Balls Deep - 5.9+</item>
<item>6. Jingle Bells - 5.9</item>
<item>7. Itching to Climb - 5.8</item>
<item>8. Hog Nose 5.10+</item>
<item>9. Slab Dance - 5.10</item>
<item>10. Dont Screw With My Disco - 5.11c</item>
<item>11. Variation - Dont Faint On My Disco - 5.11c</item>
<item>12. Faint - 5.11d</item>
<item>13. Fracture - 5.11</item>
<item>14. Tap Dance - 5.10</item>
<item>15. Puss In Boots - 5.9+</item>
<item>16. Two Bolts No Balls - 5.9</item>
<item>17. Variation - Corny Alternate Start - 5.10</item>
<item>18. Corny (Dennys Route) - 5.9</item>
<item>19. Bye Bye Bolt - 5.9</item>
<item>20. Angry White Men - 5.11b</item>
<item>21. Monkey Boy - 5.12b</item>
<item>22. Monkey Girl - 5.9+</item>
<item>23. Variation - UCGB Slab Start - 5.10b/c</item>
<item>24. UCGB - 5.10b/c</item>
<item>25. The Sixth Element - 5.6</item>
<item>Overview of the Orange Sunshine Wall Climbing Area</item>
<item>1. Sultans Of Swing - 5.6</item>
<item>2. Dirty Swing - 5.7</item>
<item>3. Dirty Thing - 5.9+/10</item>
<item>4. Orange Sunshine - 5.9</item>
<item>5. Jays - 5.10</item>
<item>6. Gym Dandy - 5.11c</item>
<item>7. Iodine-125 - 5.11a</item>
<item>8. Bottom Fishing - 5.9+</item>
<item>9. Bottom Feeder - 5.8+</item>
<item>10. Rocky And Bulwinkle - 5.5</item>
<item>Overview of the Neophytes Wall Climbing Area</item>
<item>1. Coke And Hoes - 5.7</item>
<item>2. Super Lube - 5.7</item>
<item>3. Neophytes Delight - 5.6</item>
<item>4. Dancing Nancy - 5.7</item>
<item>5. Triple Boots Blithering Brisket - 5.9</item>
<item>6. Triple S - 5.4</item>
<item>7. Whimpering Wookiee - 5.7</item>
<item>8. Turkish Delight - 5.9</item>
<item>9. Matthews Climb - 5.6</item>
<item>10. Cheese Burger EC - 5.2</item>
<item>11. Connors Climb - 5.2</item>
<item>Overview of the Zorro Wall Climbing Area</item>
<item>1. Bee Sting BeeStrong - 5.7</item>
<item>2. Red Skin - 5.9</item>
<item>3. Geronimo - 5.11</item>
<item>4. Got Choss - 5.7</item>
<item>5. Jengaistic - 5.8</item>
<item>6. Liken The Lichen - 5.8</item>
<item>7. Clown Shoes - 5.8+</item>
<item>8. Face O Meter - 5.10</item>
<item>9. Face Is Great - Choss Is Off - 5.8+</item>
<item>10. Zorro - 5.12a</item>
<item>11. Zorro Corner(Son Of Zorro) - 5.8+</item>
<item>12. Jenga - 5.9+</item>
<item>13. Pinch Six - 5.6</item>
<item>14. Slippery When Wet - 5.8+</item>
<item>Overview of the Mid Wall Climbing Area</item>
<item>1. Crying Ryan - 5.9+</item>
<item>2. Click Click Boom - 5.12b</item>
<item>3. If By Left - 5.9</item>
<item>4. If By Right - 5.11c</item>
<item>Overview of the Big Wall Climbing Area</item>
<item>1. CT7 - 5.11d</item>
<item>2. Romania - 5.14</item>
<item>3. Batman - 5.11</item>
<item>4. The Space Between - 5.11a</item>
<item>5. Laid Back And Well Hung - 5.11c</item>
<item>6. Twisted Sister - 5.11d</item>
<item>7. Groovin - 5.11d</item>
<item>8. Flippin The Bird - 5.13</item>
<item>9. Welcome To The Bird - 5.12b/c</item>
<item>10. Hinterland - 5.10b *2nd Pitch 5.12d</item>
<item>11. Opposing Gravity - 5.10 *2nd Pitch 5.13b/c</item>
<item>12. The Streak - 5.10 *2nd Pitch 5.13</item>
<item>13. Alpine Line - 5.9 *2nd Pitch 5.12d</item>
<item>14. Erics Project - 5.13</item>
<item>15. Broken Bit - 5.12</item>
<item>16. Wrecking Ball - 5.12</item>
<item>Lebowski Wall</item>
<item>1. The Dude Abides - 5.10</item>
<item>2. If You Will It, Its No Dream - 5.11</item>
<item>3. Nice Marmot - 5.11</item>
<item>4. Pretty Strict, UH, Drug Regimen - 5.8+</item>
<item>5. Shut Up Donny - 5.9</item>
<item>West Wall</item>
<item>1. Where The Wild Things Are - 5.10</item>
<item>2. Precarious - 5.10c</item>
<item>3. Spit On It - 5.10d</item>
<item>4. Crackalicious - 5.12c</item>
<item>5. Hot Pockets - 5.12b</item>
<item>Sun Wall</item>
<item>1. Uwe Come To America - 5.10+</item>
<item>2. The Virgin Suicides - 5.9+</item>
<item>3. Fear Re-Factored - 5.10+</item>
<item>4. Fear/Virgin Crossover - 5.9+</item>
<item>5. Smear Factor - 5.12c/d</item>
<item>6. Slime Factor - 5.10b</item>
<item>7. Pennsyltucky - 5.11b/c</item>
<item>8. Nine Line - 5.9</item>
<item>9. Will It Stay Or Will It Go - 5.10</item>
<item>10. Spiders And Snakes - 5.9+</item>
<item>11. Like A Slabby Virgin - 5.9</item>
<item>12. Slabtastic - 5.9+</item>
<item>13. High Steppin - 5.8</item>
<item>14. Ghetto Palm - 5.10+</item>
</string-array>
<integer-array name="routeImages">
<item>@drawable/birdsboroicon</item>
<item>@drawable/birdsboroareamap</item>
<item>@drawable/mainwall</item>
</integer-array>
</resources>