0
package com.coltonnicotera.londontransitguide;
//bunch of imports
public class SchedulesActivity extends Activity {
/** Called when the activity is first created. */
List<Map<String, String>> routesList = new ArrayList<Map<String,String>>();
String[] routesArray = new String[] {"01. Kipps Lane/Thompson Road", "02. Dundas", "03. Hamilton Rd", "04. Oxford East", "05. Springbank", "06. Richmond", "07. Wavell", "08. Riverside", "09. Whitehills", "10. Wonderland", "11. Southcrest", "12. Warncliffe South", "13. Wellington Road", "14. Highbury", "15. Westmount", "16. Adelaide", "17. Oxford West", "19. Oakridge", "20. Cherryhill", "21. Huron Heights", "22. Trafalgar", "23. Berkshire", "24. Baseline", "25. Kilally", "26. Jalna Blvd. West", "27. Fanshawe College", "28. Lambeth", "30. Newbold", "31. Orchard Park", "32. Windermere", "33. Proudfoot", "34. Medway", "35. Argyle", "36. Airport/Industrial", "37. Sovereign Road", "38. Stoney Creek", "39. Fanshawe West"};
public void onCreate(Bundle savedInstanceState) {
initList();
ListView lv = (ListView) findViewById(R.id.listView);
SimpleAdapter simpleAdpt = new SimpleAdapter(this, routesList, android.R.layout.simple_list_item_1, new String[] {"route"}, new int[] {android.R.id.text1});
/*LINE 63 */ lv.setAdapter(simpleAdpt);
}
private void initList() {
for (int i = 0; i<=36; i++)
routesList.add(createRoute("route", routesArray[i]));
}
private HashMap<String, String> createRoute(String key, String name) {
HashMap<String, String> route = new HashMap<String, String>();
route.put(key, name);
return route;
}
}
我的問題是,在第63行有一個NullPointerException。我不確定到底什麼是空的。爲了簡單起見,我刪除了所有導入。 R.id.listView也存在。SimpleAdapter null?
這必須有前這是我第三次忘記這一點。謝謝! – nicocolton 2013-02-16 19:22:29
現在我得到這個:02-16 19:22:39.482:E/AndroidRuntime(1074):android.app.SuperNotCalledException:Activity {com.coltonnicotera.londontransitguide/com.coltonnicotera.londontransitguide.SchedulesActivity}沒有通過調用到super.onCreate() – nicocolton 2013-02-16 19:23:18
是在您的onCreate(Bundle savedInstancestate)方法中調用super.onCreate() – Pragnani 2013-02-16 19:24:06