Android Question Pass value to function

Alisson

Active Member
Licensed User
Hello.

I have one listview.
If clicked one line, show the value name and position number. Example:

B4X:
             boton1.Initialize("boton1")
    boton1.TextColor = Colors.Black
    boton1.Text = "Volver al MyList."
    'panelg.AddView(boton1, 0dip, 0dip, 100%x, 9%y)
   
    Bitmap1.Initialize(File.DirAssets, "1.png")
    Bitmap2.Initialize(File.DirAssets, "2.png")
    Bitmap3.Initialize(File.DirAssets, "3.png")
    Bitmap4.Initialize(File.DirAssets, "4.png")
    Bitmap5.Initialize(File.DirAssets, "5.png")   
    Bitmap6.Initialize(File.DirAssets, "6.png")   
    Bitmap7.Initialize(File.DirAssets, "7.png")               
   

' Crea MyList (ListView)
    MyList.Initialize("MyList")
    MyList.Color=Colors.Black
    MyList.TwoLinesLayout.ItemHeight = 50dip
    MyList.TwoLinesLayout.Label.TextSize = 10dip
    MyList.TwoLinesLayout.Label.TextColor = Colors.Blue
    MyList.TwoLinesLayout.Label.Gravity = Gravity.CENTER
    MyList.FastScrollEnabled=True
    MyList.clear
    MyList.AddTwoLinesAndBitmap("OneName", "Private",Bitmap1) 
    MyList.AddTwoLinesAndBitmap("TwoName", "Private", Bitmap2)
    MyList.AddTwoLinesAndBitmap("ThreeName", "Private", Bitmap3)
    MyList.AddTwoLinesAndBitmap("FourName", "Private", Bitmap4)
    MyList.AddTwoLinesAndBitmap("FiveName", "Private", Bitmap5)
    MyList.AddTwoLinesAndBitmap("SixName", "Private", Bitmap6)
    MyList.AddTwoLinesAndBitmap("SevenName", "Private", Bitmap7)
    Activity.AddView(MyList, 0dip, 0dip, 100%x, 420dip)
    Activity.AddMenuItem("Back","boton_menu")

Sub listado_ItemClick (Position As Int, Value As Object)

Dim Myvariable = Position " & " Value
' Position is a number, example 1
' Value is name, example: OneName

How can pass the name "Private" to function?

Thanks very much
 

DonManfred

Expert
Licensed User
Longtime User
You can use a map to store more than just the bitmap in the returnvalue.

B4X:
dim m as map
m.initialite
m.put("Line1","OneName")
m.put("Line2","Private")
m.put("Bitmap",Bitmap1)
MyList.AddTwoLinesAndBitmap("OneName", "Private",m)
 
Upvote 0

Alisson

Active Member
Licensed User
I try your example. Its ok, but have the code:

B4X:
Sub listed_ItemClick (Position As Int, Value As Object)
    Msgbox(m.Get(2),m.Get(2))
Sub End

Not show the value.

It's wrong?
 
Upvote 0
Top