[WM15] Display HTML formatted Content on Android

Startbeitrag von AndyD am 26.08.2010 08:33

Hi!

Did anyone of you found a way to display html-formatted Content on an Android Device? I just need some simple formatting like Bold, Italics, Underline and Links.

Any hints are very welcome.

Best regards
Andreas

Antworten:

Hi Andreas
as far as I know HTML can only be displayed browser. I use Opera...

Regards
Hans

von Hans60 - am 26.08.2010 08:58
ups... I was refering to mobile 6. On android it may be possible I have not tried.

von Hans60 - am 26.08.2010 09:00
Hi Andreas,

You need to fire-off the document in the stock (or default) browser.
If you are running Android Donut (1.6) or above, the below code will work.
Make sure the full path of the document is passed to the procedure.

Create a global java procedure and paste in the below code:


import android.content.Intent;
import android.net.Uri;
import android.content.Context;

public static void viewFile(String myFile)
{

Context context = getApplicationContext();
Intent vwIntent = new Intent (Intent.ACTION_VIEW, Uri.parse (myFile));
vwIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(vwIntent);
}



In Windev, call the procedure to pass what document you want to view. It should
be formatted as "file://" ...


viewFile("file://sdcard/mydoc/mydoc.html")


Hope this helps,

Thanks
Georgio


von Georgio - am 30.08.2010 17:24
Thank you Georgio for your time and effort, i appriciate that.

I have already found an example like the one you posted, but i would need a way to display html-content inside a normal view. I have a small App which should display news, and the newsdetail is formatted with html tags.

I have found the function "fromHTML" (http://developer.android.com/reference/android/text/Html.html) but until now i have not found a way how to get the result into a static for example.

Best regards
Andreas

von AndyD - am 31.08.2010 08:13
Hi Andreas,


import android.text.Html;

public static String viewHtml(String myString)
{
CharSequence htmlText;
htmlText = Html.fromHtml(myString);
return htmlText.toString();
}



In Windev:

STC_Whatever = viewHtml(WhatEverString)



I rather use other plug-ins in android to display HTML (hence my suggestion
to fire-off the result in a browser). The fromHtml method doesn't support
all HTML tags.


Hope this helps.

Thanks
Georgio


von Georgio - am 31.08.2010 20:34
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.