This is a repost from the german forum
Hi there,
I just wanted to give my colleagues a little RSS reader for his desk tablett.
I've downloaded the example RSS_Reader.zip ...
http://www.b4x.com/android/forum/threads/rss-feed.15382/#post87266
Changed the feed and it works.
Now I would like, to show the current time and date on the big screen, beside the listview.
Showing the current time and date works, but then the feed reading and displaying does not. If the show-time sub is not included, the feed works.
What am I doing wrong?
Thanks for your help!!!!
Hi there,
I just wanted to give my colleagues a little RSS reader for his desk tablett.
I've downloaded the example RSS_Reader.zip ...
http://www.b4x.com/android/forum/threads/rss-feed.15382/#post87266
Changed the feed and it works.
Now I would like, to show the current time and date on the big screen, beside the listview.
Showing the current time and date works, but then the feed reading and displaying does not. If the show-time sub is not included, the feed works.
What am I doing wrong?
Thanks for your help!!!!
B4X:
#Region Project Attributes
#FullScreen: True
#IncludeTitle: True
#ApplicationLabel: BD-iClock
#VersionCode: 0
#VersionName: 0.0
#SupportedOrientations: landscape
#CanInstallToExternalStorage: true
#End Region
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim Parser As SaxParser
Dim web As PhoneIntents
Dim hc As HttpClient
Dim req As HttpRequest
Dim PubDate As String
End Sub
Sub Globals
Dim RSS As ListView
Dim Title, Link, Description As String
Dim Label1 As Label
Dim Label2 As Label
Dim Label3 As Label
Dim DATUM As String
Dim ZEIT As String
Dim NOW As Long
Dim JA As Boolean
Dim ENDE As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
JA=True
DateTime.DateFormat="dd.MM.yyyy"
Activity.LoadLayout("Main")
Wait1(3)
Parser.Initialize
hc.Initialize("hc")
req.InitializeGet("http://www.tagesschau.de/newsticker.rdf")
hc.Execute(req, 1)
DoEvents
Do While JA=True
show_time
DoEvents
Wait1(1)
Loop
End Sub
Sub Activity_Resume
Do While JA=True
show_time
DoEvents
Wait1(1)
Loop
End Sub
Sub Activity_Pause(UserClosed As Boolean)
End Sub
Sub RSS_ItemClick(Position As Int, Value As Object)
StartActivity(web.OpenBrowser(Value)) 'Open the browser with the link
End Sub
Sub hc_ResponseSuccess(Response As HttpResponse, TaskId As Int)
Response.GetAsynchronously("GetRSS", File.OpenOutput(File.DirDefaultExternal, "RSS.xml", False), True, TaskId)
End Sub
Sub hc_ResponseError(Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
If Response <> Null Then
Msgbox("Error: " & Response.GetString("UTF8"), "Connection Error")
Response.Release
End If
End Sub
Sub GetRSS_StreamFinish(Success As Boolean, TaskId As Int)
If Success = False Then
Msgbox(LastException.Message, "Error")
Return
End If
Dim In As InputStream
In = File.OpenInput(File.DirDefaultExternal, "RSS.xml")
Parser.Parse(In, "Parser")
In.Close
End Sub
Sub Parser_StartElement(Uri As String, Name As String, Attributes As Attributes)
End Sub
Sub Parser_EndElement(Uri As String, Name As String, Text As StringBuilder)
If Parser.Parents.IndexOf("item") > -1 Then
If Name = "title" Then
Title = Text.ToString
Else If Name = "link" Then
Link = Text.ToString
Else If Name = "pubdate" Then
PubDate = Text.ToString
Else If Name = "description" Then
Description = Text.ToString
End If
End If
If Name = "item" Then
RSS.TwoLinesLayout.Label.Gravity = Gravity.TOP
RSS.TwoLinesLayout.Label.TextSize = 9dip
RSS.TwoLinesLayout.Label.Height =100dip
RSS.TwoLinesLayout.ItemHeight = 100dip
RSS.TwoLinesLayout.SecondLabel.TextSize = 8dip
RSS.TwoLinesLayout.SecondLabel.Height = 100dip
RSS.AddTwoLines2(Title, Description, Link)
End If
End Sub
Sub Wait1(Seconds As Int)
'Sleep for defined seconds
Dim Ti As Long
Ti = DateTime.NOW + (Seconds * 1000)
Do While DateTime.NOW < Ti
DoEvents
Loop
End Sub
Sub show_time()
NOW = DateTime.NOW
DATUM=DateTime.Date(NOW)
ZEIT= DateTime.Time (NOW)
Label1.Text = ZEIT
Label2.Text = ZEIT
Label3.Text = DATUM
End Sub