I am working with the Net Library and MailParser. What view should be used to display an email message Body having HTML and Text, or plain Text only? The view would have to handle both formats and be scrollable.
Currently I can only view a plain Text message Body. A message Body in HTML displays the configuration info. I have thought of using a WebView, but have no idea how this would be implemented. Any help greatly appreciated.
Thank you Erel. The code snipit below worked for me, but I find that vertical scrolling in the WebView is very erratic. It will take a few swipes before things will scroll for that one swipe. Then it will take as many a six to nine swipes before things again scroll for that one swipe. I have tested my app on an HP Slate running Android 4.2.2, an a Samsung Note 10.1 running Android 4.1.2. Is there anything I can do to make scrolling reliable and smooth? I should mention that I get the same erratic behavior when using the emulator.
Best regards
B4X:
' MsgBody is a string
If MsgBody.Contains("CRLF") = True Then
MsgBody = MsgBody.Replace(CRLF, "<br/>") ' use "<p/>" for paragraph - otherwise "<br/>" for CRLF.
End If
WebViewBody.LoadHtml(MsgBody)
EDIT: This issue has been resolved. In a search of this Forum I found a more efficient way of dealing with the WebView.
Yes, I should have. Here it is. I first tried creating the WebView in the designer, with a dedicated Panel as the parent. This worked, however the WebView was sluggish and unreliable. My solution was to create the WebView in code as an Activity. This works very well. The code below is a basic illustration.
Best regards
B4X:
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim WebViewBody As WebView
Dim MsgBody As String
End Sub
Sub Activity_Create(FirstTime AsBoolean)
WebViewBody.Initialize("")
Activity.AddView(WebViewBody, 0, 0, -1, -1)
WebViewBody.LoadHtml(MsgBody)
End Sub