2013-02-04 39 views
0

我的列表视图没有填充我从MySQL数据库提取的数据。我测试了Web服务,一切都很完美。我正在调试它,我注意到,当我在asynctask中设置断点时,它永远不会去那里。我离开了执行命令,它从未进入内部。一切运行良好,没有错误。我很困惑和新,请温柔。使用断点进行调试永远不会进入子类

public class Favorites extends Activity{ 
    UserFunctions userFunctions = new UserFunctions(); 
    ArrayList<String> zipcodes = new ArrayList<String>(0); 
    ArrayAdapter<String> arrayAdapter1; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.favoritespage); 
    arrayAdapter1 = new ArrayAdapter<String>(Favorites.this,android.R.layout.activity_list_item,zipcodes); 
    new DownloadDataTask().execute(); 
} 

@Override 
public boolean onCreateOptionsMenu(Menu menu) { 
    // Inflate the menu; this adds items to the action bar if it is present. 
    getMenuInflater().inflate(R.menu.activity_main_screen, menu); 
    return true; 
} 

private class DownloadDataTask extends AsyncTask<JSONArray, JSONArray, ArrayList<String> > { 
    @Override 
    protected ArrayList<String> doInBackground(JSONArray... params) { 
    JSONArray json = userFunctions.ziplistrequest("37.5", "140.45", "20"); 
    for(int i=0; i < json.length() ; i++) { 
     JSONObject jarray = null; 
     try { 
     jarray = json.getJSONObject(i); 
     String zip = jarray.getString("ZIPCODE"); 
     zipcodes.add(zip); 
     arrayAdapter1.add(zip); 
     Log.d(zip,"Output"); 
     } catch (JSONException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
     } 
    } 
    return zipcodes; 
    } 
    protected void onPostExecute(){ 
    ListView listView = (ListView) findViewById(R.id.list); 
    listView.setAdapter(arrayAdapter1); 
    } 
} 

如果需要任何额外的答案,请让我知道。

+1

如果直接贴在调试点上的异步任务''''doInBackground''''会发生什么?清理并构建您的项目(如果使用Eclipse IDE),以防发生编译器/类生成问题。 – OceanLife

+0

+1,如果它不起作用,尝试从执行调用中进入代码。但我真的没有看到任何问题。 – psykhi

+0

我清理了它,然后进入了断点。非常感谢!我在想这是代码。好吧,它必须是代码中的东西,为什么它不显示我的列表。会看到doinbackground在调试中的作用。 – Mark

回答

0

好东西。我要添加评论作为一个答案对于Q &的封盖和纯有那么点贪心:)

如果直接贴在调试点上的异步任务 doInBackground会发生什么?清洁&建设项目的情况下,(如果使用的Eclipse IDE) 有一些编译器/类生成问题

相关问题