My listview is not being populated with the data I am pulling from a MySQL database. I have tested the web service and everything is perfect. I was debugging it and I noticed that when I set a breakpoint inside my asynctask it never went there. I stepped from the execute command and it never went inside. Everything runs fine with no errors. I am confused and new, please be gentle.
我的listview没有填充我从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);
}
}
If any additional answers are needed please let me know.
如果需要任何其他答案,请告诉我。
1 个解决方案
#1
0
Good stuff. I'll add my comment as an answer for Q&A closure and pure SO point greed :)
好东西。我将添加我的评论作为Q&A关闭和纯SO点贪婪:)的答案:)
What happens if you stick the debug point directly on the async task doInBackground? Clean & build your project (if using an Eclipse IDE) in case there are some compiler/class generation issues
如果将调试点直接粘贴在异步任务doInBackground上会发生什么?如果存在编译器/类生成问题,请清理并构建项目(如果使用Eclipse IDE)
#1
0
Good stuff. I'll add my comment as an answer for Q&A closure and pure SO point greed :)
好东西。我将添加我的评论作为Q&A关闭和纯SO点贪婪:)的答案:)
What happens if you stick the debug point directly on the async task doInBackground? Clean & build your project (if using an Eclipse IDE) in case there are some compiler/class generation issues
如果将调试点直接粘贴在异步任务doInBackground上会发生什么?如果存在编译器/类生成问题,请清理并构建项目(如果使用Eclipse IDE)