我一直在运行这段代码(除了onCreate
因为我必须先从网上检索数据),它就停在线上mainView.setAdapter
,永远不会进入下一个调试语句(或为此加载数据)。我究竟做错了什么?
private void loadInteractions(JSONArray interactions){
mainView = (ListView) findViewById(R.id.list);
myInteractionsTask.cancel(false);
String[] interactionsArray=new String[interactions.length()];
for(int interactionCounter=0; interactionCounter<interactions.length();interactionCounter++){
TextView interactionView = new TextView(this);
Log.d("Debug", "Loading Interaction #"+interactionCounter);
try {
Log.d("Debug", "Loading text: "+interactions.getString(interactionCounter));
interactionsArray[interactionCounter]=interactions.getString(interactionCounter);
Log.d("Debug", "Done loading text");
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
mainView.setAdapter(new ArrayAdapter<String>(this, R.id.list, interactionsArray));
Log.d("Debug", "Done loading textView");
}