Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Foreign Languages > Spanish Forum
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Ayuda listando ficheros de un directorio

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-18-2012, 10:21 PM
Knows the basics
 
Join Date: Jul 2011
Posts: 89
Default Ayuda listando ficheros de un directorio

Buenas chicos, pues mi primera pregunta tras la presentacion es para ver si me echais un cable con el codigo para lo que estoy haciendo.

Me gustaria mostrar en un ListView los ficheros que hay en un directorio y que al seleccionar uno de la lista se carge en un imagebox.

A ver si me ayudais a iniciarlo, muchas gracias.
Reply With Quote
  #2 (permalink)  
Old 01-19-2012, 01:17 PM
Basic4ppc Veteran
 
Join Date: Nov 2011
Location: Spain
Posts: 275
Post

Te he escrito un ejemplo. Me he basado en el código de este hilo para crear un ejemplo sencillo que enseña lo que entiendo que quieres conseguir.

Hace una lista de las imágenes guardadas por la cámara y de la que seleccionas, muestra un trozo en un ImageView.

Adjunto el programa, y aquí pego el código:

Code:
Sub Process_Globals
End Sub

Sub Globals
    
Dim ListView1 As ListView
    
Dim ImageView1 As ImageView
    
Dim Label1 As Label
    
    
Dim path1,file1 As String
End Sub

Sub Activity_Create(FirstTime As Boolean)

  
Dim GD As GradientDrawable
  GD.Initialize(
"TR_BL"Array As Int(Colors.Blue, Colors.LightGray))
  Activity.Background = GD
    
    ListView1.Initialize(
"ListView1")
  ListView1.ScrollingBackgroundColor = 
Colors.Transparent
    
    ImageView1.Initialize(
"test")
    ImageView1.Color = 
Colors.ARGB(25,0,0,0)
    
    Label1.Initialize(
"Label1")
    Label1.Color = 
Colors.argb(90,0,0,0)
    Label1.TextColor = 
Colors.Yellow
    Label1.TextSize = 
9

  ListView1.SingleLineLayout.ItemHeight = 
50dip
  ListView1.SingleLineLayout.Label.TextSize = 
20
  ListView1.SingleLineLayout.Label.TextColor = 
Colors.White
  ListView1.SingleLineLayout.Label.Gravity = 
Gravity.LEFT
  ListView1.FastScrollEnabled = 
True

  root=
File.DirRootExternal
  path1 = root & 
"/DCIM/Camera"

  ListFolderContent(path1)

    Activity.AddView(ListView1, 
00100%x50%y)
    Activity.AddView(Label1, 
050%y100%x30dip)
    Activity.AddView(ImageView1, 
0, (50%y + 30dip), 100%x50%y)

End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub ListFolderContent(folder As StringAs String
  
Dim fileList As List
  
Dim n As Int

  fileList = 
File.ListFiles(path1)
  fileList.Sort(
True)

  
For n = 0 To fileList.Size-1
    file1 = fileList.Get(n)
        ListView1.AddSingleLine(file1)
  
Next
End Sub


Sub ListView1_ItemClick (Position As Int, Value As Object)
    Activity.Title = 
"Selected: ("& Position &") <" & Value &" >"
        
        
Try
            ImageView1.Bitmap = 
LoadBitmapSample(path1,Value, ImageView1.Width, ImageView1.Height)
            Label1.Text = 
"Ok."
        
Catch
            Label1.Text = 
"error " & LastException
        
End Try
End Sub
Para más información aquí tienes un tutorial de ListView. Y el imagebox de VB aquí se llama Imageview.

que lo disfrutes!

EDIT: Copiado al foro inglés.
Attached Files
File Type: zip ListviewDircontentImagebox.zip (6.1 KB, 9 views)

Last edited by joseluis : 01-19-2012 at 01:30 PM. Reason: link to the english thread
Reply With Quote
  #3 (permalink)  
Old 01-19-2012, 10:54 PM
Knows the basics
 
Join Date: Jul 2011
Posts: 89
Default

Muchisimas gracias joseluis, si es lo que quiero, tengo hecha una parte pero este codigo me hara poder acabar mi aplicacion.

Gracias una vez mas. Un saludo.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Abrir ficheros de word,excel, pdf. Fosi Spanish Forum 2 05-12-2011 04:31 PM
Ayuda problema al compilar miguelrprey Spanish Forum 1 04-22-2009 05:48 PM


All times are GMT. The time now is 01:17 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0