Sto utilizzando un ListAdapter per popolare un ListView come questo:Come reimpostare il ListView con l'ArrayAdapter dopo il recupero dei dati
static final String[] PROBLEMS = new String[] {"one", "two", "three" };
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(this, R.layout.my_problems, PROBLEMS));
ListView lv = getListView();
lv.setTextFilterEnabled(true);
e dopo che sto facendo una chiamata remota al mio server per ottenere più dati per quella lista con una chiamata AsyncTask, e quando ottengo i dati dal server non so come popolare e ripristinare il ListView. Finora ho qualcosa di simile:
@Override
protected void onPostExecute(String result)
{
// Unwrap the stuff from the JSON string
String problem_title = null;
String problem_id = null;
try
{
JSONArray obj = new JSONArray(result);
JSONObject o = obj.getJSONObject(0);
Log.d("Title: " , "" + o.getString("problem_title"));
Log.d("id: " , "" + o.getString("problem_id"));
problem_title = o.getString("problem_title");
problem_id = o.getString("problem_id");
}
catch (Exception e)
{
}
// Now not sure what to do :)
// How do I reset the list that I had set up above?
}
posso fare il risultato in dati strutturati in modo appropriato per reimpostare l'elenco, ma non sono sicuro di come questo è fatto. Qualcuno può aiutarmi per favore? :)
Lasciatemi provare ora ... ti dirò come è andata :) – GeekedOut
ah ok, si sta compilando! Grazie! – GeekedOut
Nessun problema, buona fortuna –