Pueden decirme este error? no lo consigo. y no me muestra nada.
Código Java:
Ver originalimport android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import com.herprogramacion.restaurantericoparico.R;
import com.herprogramacion.restaurantericoparico.parser.JSONParser;
import com.herprogramacion.restaurantericoparico.parser.ServiceHandler;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
public class Frag_Clasi extends ListFragment {
// URL to get contacts JSON
private static String url
= "http://cadetes.esy.es/conexion/Clasificacion/prueva4.php";
// JSON Node names
private static final String TAG_CAD_JUG
= "listaJugadores"; private static final String TAG_NOMBRE
= "posicion";
ArrayList
<HashMap
<String, String
>> jsonlist
= new ArrayList
<HashMap
<String, String
>>();
JSONArray contacts = null;
@Override
public View onCreateView
(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
setRetainInstance(true);
return inflater.inflate(R.layout.cad_jug_list, container, false);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
new ProgressTask(Frag_Clasi.this.getActivity()).execute();
super.onActivityCreated(savedInstanceState);
}
private class ProgressTask
extends AsyncTask
<String,
Void, Boolean
> { private ProgressDialog dialog;
public ProgressTask
(Context ListFragment
) {
Log.i("1", "Called");
context = ListFragment;
dialog = new ProgressDialog(context);
}
protected void onPreExecute() {
this.dialog.setMessage("Iniciando....");
this.dialog.show();
}
@Override
protected void onPostExecute
(final Boolean success
) { if (dialog.isShowing()) {
dialog.dismiss();
}
ListAdapter adapter = new SimpleAdapter(context, jsonlist, R.layout.cad_jug_row,
new String[] { TAG_NOMBRE
},
new int[] { R.id.nombre });
setListAdapter(adapter);
lv = getListView();
}
JSONParser jParser = new JSONParser();
ServiceHandler sh = new ServiceHandler();
String jsonStr
= sh.
makeServiceCall(url, ServiceHandler.
GET);
if (dialog.isShowing()) {
dialog.dismiss();
}
try {
JSONObject jsonObj = new JSONObject(jsonStr);
// Getting JSON Array node
contacts = jsonObj.getJSONArray(TAG_CAD_JUG);
// looping through All Contacts
for (int i = 0; i < contacts.length(); i++) {
JSONObject c = contacts.getJSONObject(i);
String nombre
= c.
getString(TAG_NOMBRE
);
// Phone node is JSON Object
HashMap
<String, String
> map
= new HashMap
<String, String
>();
map.put(TAG_NOMBRE, nombre);
jsonlist.add(map);
}
} catch (JSONException Obj) {
Obj.printStackTrace();
}
return null;
}
}
}