Tema: [ SOLUCIONADO ] utf8
Ver Mensaje Individual
  #1  
Viejo 27/02/16, 20:58:17
Array

[xs_avatar]
Merche300 Merche300 no está en línea
Betatester oficial
 
Fecha de registro: dic 2008
Localización: Valencia
Mensajes: 625
Modelo de smartphone: NEXUS 5 - ONEPLUS 3
Tu operador: Pepephone
utf8

Pues eso, la ñ esta desaparecida, y en el php si se ve, ¿Alguna solucion con la clase ? Por que en el json se ve perfectamente, en minuscula eso si pero no se ven los caracteres raros. Gracias

Código:
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import com.herprogramacion.restaurantericoparico.R;
import com.herprogramacion.restaurantericoparico.Ranking_Amonestaciones_Cadetes;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;


public class Ranking_Amonestaciones_Adapter_Juveniles extends ArrayAdapter {

    // Atributos
    private RequestQueue requestQueue;
    JsonObjectRequest jsArrayRequest;
    private static final String URL_BASE = "http://cadetes.esy.es/2015/amonestados_juvenil.php";
    private static final String URL_JSON = "";
    private static final String TAG = "";
    List<Ranking_Amonestaciones_Cadetes> items;

    public Ranking_Amonestaciones_Adapter_Juveniles(Context context) {
        super(context,0);

        // Crear nueva cola de peticiones
        requestQueue= Volley.newRequestQueue(context);

        // Nueva peticion JSONObject
        jsArrayRequest = new JsonObjectRequest(
                Request.Method.GET,
                URL_BASE + URL_JSON,
                null,
                new Response.Listener<JSONObject>() {
                      @override
                    public void onResponse(JSONObject response) {
                        items = parseJson(response);
                        notifyDataSetChanged();
                    }
                },
                new Response.ErrorListener() {
                      @override
                    public void onErrorResponse(VolleyError error) {
                        Log.d(TAG, "Error Respuesta en JSON: " + error.getMessage());

                    }
                }
        );

        // Anyadir peticion a la cola
        requestQueue.add(jsArrayRequest);
    }

      @override
    public int getCount() {
        return items != null ? items.size() : 0;
    }

      @override
    public View getView(int position, View convertView, ViewGroup parent) {

        LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());

        // Referencia del view procesado
        View listItemView;

        //Comprobando si el View no existe
        listItemView = null == convertView ? layoutInflater.inflate(
                R.layout.ranking_amonestaciones_cadetes_row,
                parent,
                false) : convertView;


        // Obtener el item actual
        Ranking_Amonestaciones_Cadetes item = items.get(position);

        // Obtener Views
        TextView textoNombre = (TextView) listItemView.findViewById(R.id.tv_nombre_local);
        TextView textoTargetas = (TextView) listItemView.findViewById(R.id.tv_goles);
        TextView textoAmarillas = (TextView) listItemView.findViewById(R.id.tv_dobles);
        TextView textoDobles = (TextView) listItemView.findViewById(R.id.tv_amarillas);
        TextView textoRojas = (TextView) listItemView.findViewById(R.id.tv_rojas);
        TextView textoEquipo = (TextView) listItemView.findViewById(R.id.tv_equipo);


        // Actualizar los Views
        textoNombre.setText(item.getNombre());
        textoTargetas.setText(item.getTargetas());
        textoAmarillas.setText(item.getAmarillas());
        textoDobles.setText(item.getDobles());
        textoRojas.setText(item.getRojas());
        textoEquipo.setText(item.getEquipo());





       // Anyadir peticion a la cola



        return listItemView;
    }

    public List<Ranking_Amonestaciones_Cadetes> parseJson(JSONObject jsonObject){
        // Variables locales
        List<Ranking_Amonestaciones_Cadetes> rankingAmonestacionesCadetes = new ArrayList<>();
        JSONArray jsonArray= null;

        try {
            // Obtener el array del objeto
            jsonArray = jsonObject.getJSONArray("maxAmonestados");

            for(int i=0; i<jsonArray.length(); i++){

                try {
                    JSONObject objeto= jsonArray.getJSONObject(i);

                    Ranking_Amonestaciones_Cadetes RankingAmonestacionesCadetes = new Ranking_Amonestaciones_Cadetes(
                            objeto.getString("nombre"),
                            objeto.getString("totalTarjetas"),
                            objeto.getString("amarillas"),
                            objeto.getString("dobles"),
                            objeto.getString("rojas"),
                            objeto.getString("equipo"));


                    rankingAmonestacionesCadetes.add(RankingAmonestacionesCadetes);

                } catch (JSONException e) {
                    Log.e(TAG, "Error de parsing: " + e.getMessage());
                }
            }

        } catch (JSONException e) {
            e.printStackTrace();
        }


        return rankingAmonestacionesCadetes;
    }
}

Última edición por Merche300 Día 02/04/16 a las 21:52:18.
Responder Con Cita