CERCA
PER MODELLO
FullScreen Chatbox! :)

Utente del giorno: megthebest con ben 1 Thanks ricevuti nelle ultime 24 ore
Utente della settimana: gianpassa con ben 8 Thanks ricevuti negli ultimi sette giorni
Utente del mese: 9mm con ben 33 Thanks ricevuti nell'ultimo mese

Visualizzazione dei risultati da 1 a 1 su 1
Discussione:

Immagini da file XML

Se questa discussione ti è stata utile, ti preghiamo di lasciare un messaggio di feedback in modo che possa essere preziosa in futuro anche per altri utenti come te!
  1. #1
    Androidiano VIP L'avatar di fintematic


    Registrato dal
    Oct 2011
    Località
    Sicilia
    Messaggi
    1,362
    Smartphone
    Xperia Play - Toshiba Folio100

    Ringraziamenti
    631
    Ringraziato 735 volte in 316 Posts
    Predefinito

    Immagini da file XML

    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ì :

    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
    Facendo così sono riuscito a ottenere testo, descrizione e link che ho inserito nella listview.
    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?

  2.  

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire risposte
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Torna su
Privacy Policy