I have a CustomBaseAdapter with which i fill certain fields:
public ArrayList<SearchResults> GetSearchResults(){
ArrayList<SearchResults> results = new ArrayList<SearchResults>();
Document doc = Jsoup.parse(kpn);
Elements tdsFromSecondColumn = doc.select("table.personaltable td:eq(0)");
Elements tdsFromSecondColumn1 = doc.select("table.personaltable td:eq(1)");
SearchResults sr1 = new SearchResults();
for (Element tdFromSecondColumn : tdsFromSecondColumn) {
sr1 = new SearchResults();
sr1.setNaam(tdFromSecondColumn.text());
results.add(sr1);
}
for (Element tdFromSecondColumn1 : tdsFromSecondColumn1) {
sr1 = new SearchResults();
sr1.setWaarde(tdFromSecondColumn1.text());
results.add(sr1);
}
return results;
}
I want to fire this up the the onPostExecute of a AsyncTask but i get a force close:
@Override
protected void onPostExecute(String result) {
ListView kp = (ListView)findViewById(R.id.kpn);
ArrayList<SearchResults> searchResults = GetSearchResult();
kp.setAdapter(new MyCustomBaseAdapter(this, searchResults)); <--- think here is the error
progress.dismiss();
}
Is this code possible? If no what should be changed. Thank you in advance.
Ok, i got rid of the exception by doing:
But the fields are still filled incorrectly with JSoup, first all the naam fields are displayed and then the waarde fields.
It should be:
Does somebody know how to combine the 2 for loops of JSoup so that the fields are filled correctly:
Here my CustomBaseAdapter as requested: