Ciao ragazzi,
Uso Basic4Android e sto creando un'app che mi serve per visualizzare le ultime news di un sito...
Questo sono riuscito a farlo così :
Facendo così sono riuscito a ottenere testo, descrizione e link che ho inserito nella listview.codice:'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 End Sub Sub Globals 'These global variables will be redeclared each time the activity is created. 'These variables can only be accessed from this module. Dim RSS As ListView Dim Title, Link, PubDate, Description As String End Sub Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout("Main") RSS.Width = 100%x RSS.Height = 100%y Parser.Initialize hc.Initialize("hc") req.InitializeGet("http://feeds.feedburner.com/Androidiani?format=xml") hc.Execute(req, 1) End Sub Sub Activity_Resume End Sub Sub Activity_Pause(UserClosed As Boolean) End Sub '########################## '######## Controls ######## '########################## Sub RSS_ItemClick(Position As Int, Value As Object) StartActivity(web.OpenBrowser(Value)) 'Open the browser with the link End Sub '############################ '######## Fetch Data ######## '############################ 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 '########################## '######## Routines ######## '########################## 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 = 140dip RSS.TwoLinesLayout.ItemHeight = 140dip RSS.TwoLinesLayout.SecondLabel.TextSize = 8dip RSS.TwoLinesLayout.SecondLabel.Height = 140dip RSS.AddTwoLines2(Title, Description, Link) End If End Sub
Però oltre a questo vorrei anche visualizzare nella listview un immagine come bitmap, l'immagine di ogni nuova news
Nell'esempio qui sopra ho inserito il sito di feedburner di Androidiani ma non è questo il sito, comunque è sempre da feedburner che ricavo ciò che mi serve.
Come posso fare per inserire le immagini?

LinkBack URL
About LinkBacks
Rispondi quotando