0

I parsed a html web page with jsoup. now i want to display my parsed data in my textview.

code

    String ID = loginpreferences.getString("ID", null);
    String Type = loginpreferences.getString("Type", null);

    String myURL = "http://roosters.gepro-osi.nl/roosters/rooster.php?leerling="+ID+"&type=Leerlingrooster&afdeling="+Type+"&tabblad=2&school=905";



        Document doc = null;
        try {
            doc = Jsoup.connect(myURL).get();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        Elements data = doc.select(".1nameheader");




}    
}

I tried

Textview1.SetText(data);

But that didn't work.

Georggroenendaal
  • 314
  • 1
  • 14

3 Answers3

1

Seems as if you want to print the text values from a list of Elements. To do so you need to iterate over the list of Elements and get the text out of them.

   StringBuilder text = new StringBuilder();
   for(Element e: data){
       text.append(e.text());
   }
   Textview1.setText(text.toString());
Vincent Ramdhanie
  • 102,349
  • 23
  • 137
  • 192
0

Line

Textview1.SetText(data);

shouldn't even compile.

From Android TextView class reference:

final void   setText(CharSequence text)
             Sets the string value of the TextView.

You're giving Elements class instance to the method.

Element and Elements classes of JSoup provide you with html() and text() methods that you should use in that case.

Xeon
  • 5,949
  • 5
  • 31
  • 52
0

Have you tried android.text.html.forHtml(String)? This method gets a html as input and returns a spanned text that you cat set it to a TextView