Fill Listview with an array

Asked

Viewed 182 times

0

I have an Array List where I store the subjects with the respective grades of a particular student.

This array has only 2 attributes:

nomendDiscipline valuer

I would like to know how to fill a listview with all the disciplines and notes stored in this array.

Note: So it appears in 2 columns, the first with the DISCIPLINES header and the second with the NOTES header.

    ArrayList<Nota> listNotas = new ArrayList<>();

public ArrayList buscarNotas(String matricula, int etapa){

    try {
        SoapObject resposta = new SoapObject(NAMESPACE, METHOD_NAME);


            resposta.addProperty("Matricula", matricula);
            resposta.addProperty("Etapa", etapa);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = true;
        envelope.setOutputSoapObject(resposta);

        HttpTransportSE http = new HttpTransportSE(URL);
        http.call(SOAP_ACTION, envelope);

        String resultado = envelope.getResponse().toString();

        JSONArray jsonArray = new JSONArray(resultado);


        for(int i=0;i<jsonArray.length();i++ ) {
            Nota nota = new Nota();
            JSONObject jsonObject =jsonArray.getJSONObject(i);

            nota.setDisciplina(jsonObject.getString("Materia"));
            nota.setNota(jsonObject.getString("VlrNota"));

            listNotas.add(i,nota);
        }
    }  catch (HttpResponseException e) {
        e.printStackTrace();
    } catch (SoapFault soapFault) {
        soapFault.printStackTrace();
    } catch (XmlPullParserException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        e.printStackTrace();
    }

   return listNotas;

}
  • Could you show us what you have so far? What is the structure in which you keep the discipline with student grades ? It helps us to help you!

  • I put the code, I actually get this data from a web service and store it in a list.

  • See if this helps - http://answall.com/questions/153556/listview-com-duas-lines

  • Friend, I have another problem: When I call this method in the other class it is returning null.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.