Estoy utilizando un ListAdapter para rellenar un ListView así:Cómo restablecer el ListView con el ArrayAdapter después de ir a buscar los datos
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);
y después de que yo estoy haciendo una llamada remota a mi servidor para obtener más datos para esa lista con una llamada AsyncTask, y cuando recupero los datos del servidor no sé cómo llenar y restablecer el ListView. Hasta ahora tengo algo como esto:
@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?
}
que puede hacer que el resultado en datos estructurados apropiadamente para restablecer la lista, pero no está seguro de cómo se hace. ¿Puede ayudarme alguien, por favor? :)
Déjame intentarlo ahora ... Te diré cómo fue :) – GeekedOut
¡vale, está compilando! ¡Gracias! – GeekedOut
No hay problema, buena suerte –