I have a CustomListView that contains 10 elements consisting of a button and a horizontal CustomListView2. When I click the button with ContentChooser, I try to upload a photo from the gallery and display it on CustomListView2. How can I do that?
How can I add an image from chooser_Result to CustomListView?
B4X:
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
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 Chooser As ContentChooser
Private MyCLV As CustomListView
Private Button1 As Button
Private CLV_IV As CustomListView
Private ImageView1 As ImageView
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("Main")
Chooser.Initialize("chooser")
For i = 1 To 10
MyCLV.Add(CreateListItem("MyText"&i),i)
Next
End Sub
Sub CreateListItem(Text As String) As Panel
Dim p As Panel
p.Initialize("")
p.SetLayout(0, 0, 100%x, 150dip)
p.LoadLayout("Item")
Button1.Text = Text
Return p
End Sub
Sub CreateListItem2(btm As Bitmap) As Panel
Dim p As Panel
p.Initialize("")
p.SetLayout(0, 0, 100dip, 100dip)
p.LoadLayout("Item_IV")
ImageView1.Bitmap=btm
Return p
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
Dim index As Int = MyCLV.GetItemFromView(Sender)
Log("Checked items: " & index)
Chooser.Show("image/*", "Choose image")
End Sub
Sub chooser_Result (Success As Boolean, Dir As String, FileName As String)
If Success Then
Dim index As Int = MyCLV.GetItemFromView(Sender)
Dim pnl As B4XView = MyCLV.GetPanel(index)
Dim clv As B4XView= pnl.GetView(1)
clv.Add(CreateListItem2(LoadBitmapResize(Dir,FileName,100dip,100dip,True)),0)
End If
End Sub
B4X:
B4A Version: 8.00
Parsing code. (0.03s)
Compiling code. Error
Error compiling program.
Error description: Unknown member: add
Error occurred on line: 77
clv.Add(CreateListItem2(LoadBitmapResize(Dir,FileName,100dip,100dip,True)),0)
Word: add
Attachments
Last edited: