on Android I searched for a while, and now I just could not find the right answer for this. In short, I am returning ...">

How to handle tags <br/"> on Android

I searched for a while, and now I just could not find the right answer for this. In short, I am returning a webpage from onine to use it as a mailbox. I desperately need to skip lines between each "message", so I am adding tags
to my php. It works fine in a web browser, but in my Android app I can see tags
as plain text. Just try reading them as "next / new lines." Any ideas?

My method code:

public String getInbox(String where){

        BufferedReader in = null;
        String data = null;
        try{


            HttpClient client = new DefaultHttpClient();
            URI website = new URI("http://example.com/getInbox.php?where="+where);

            HttpPost post_request = new HttpPost();
            post_request.setURI(website);


            HttpGet request = new HttpGet();

            request.setURI(website);
            //executing actual request

                        //add your implementation here
            HttpResponse response = client.execute(request);

            in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
            StringBuffer sb = new StringBuffer("");
            String l = "";
            String nl = System.getProperty("line.separator");
            while ((l = in.readLine()) != null) {
                sb.append(l+nl);

            }
            in.close();
            data = sb.toString();


return data;
        }catch (Exception e){
            return "ERROR";

        }

        }

The output on the web page:

eg test
eg test
eg lol
eg lol
eg testing

Output in android:

eg test<br />eg test<br />eg lol<br />eg lol<br />eg testing<br />eg
+3
source share
4 answers
String lineSep = System.getProperty("line.separator");
String yourString= "test<br />eg test<br />eg lol<br />eg lol<br />eg testing<br />eg34 ernestggggg";


yourString= yourString.replaceAll("<br />", lineSep):
+9
source

, -. :

TextView tv = (TextView)findViewById(R.id.tv);
tv.setText(Html.fromHtml(  " Overs Alloted "  + "<small> <small> " + "at start of innings" + "</small> </small>" ));  //Example

String s= getStringFromSoruce(parameters);  //Pass the string you need here
tv.setText(Html.fromHtml(s));

, . html-, .

, :)

+2

You can use Html.fromHtml()to convert html to string Spannedwith any html enabled.

0
source

check it out. replace the tag with a <br />new line"\n"

data = sb.toString();

data = data.replaceAll("<br />", "\n");

return data;
0
source

All Articles