I have a CustomListView "allclv" which contains several "Photo" Layouts. Layout "Photo" contains several buttons and one more CustomListView "clvPhoto".
How can I add the selected photo to the clvPhoto where the button was clicked?
Here is my code. He does not work.
Perhaps there is another way. I need an element in the CustomListView that I can scroll horizontally and add a photo there, as well as delete the selected photo.
I'll try to describe it in more detail to make it clearer. I have a CustomListView which contains a panel where the photo is displayed, as well as two buttons to add and take a photo. There will be about 10 such panels. I need the panel where the photos will be able to scroll horizontally and contain many photos. Also, if I click on the photo, I could delete it.
How can I add the selected photo to the clvPhoto where the button was clicked?
Here is my code. He does not work.
B4X:
Sub btnAddPhoto_Click
Dim index As Int = allclv.GetItemFromView(Sender)
indexAddPhoto=index
Dim i As Intent
i.Initialize("android.intent.action.GET_CONTENT", "")
i.PutExtra("android.intent.extra.ALLOW_MULTIPLE", True)
i.SetType("image/*")
StartActivityForResult(i)
End Sub
Sub ion_Event (MethodName As String, Args() As Object) As Object
If Args(0) = -1 Then 'resultCode = RESULT_OK
Dim i As Intent = Args(1)
Dim jo As JavaObject = i
'Android 4.1+ (API 16)
Dim uris As List
uris.Initialize
Dim clipdata As JavaObject = jo.RunMethod("getClipData", Null)
If clipdata.IsInitialized Then
Dim count As Int = clipdata.RunMethod("getItemCount", Null)
For i2 = 0 To count -1
Dim item As JavaObject = clipdata.RunMethod("getItemAt", Array(i2))
uris.Add(item.RunMethod("getUri", Null))
Next
Else
uris.Add(i.GetData)
End If
Log(uris)
For j=0 To uris.Size-1
Dim pnl As B4XView = allclv.GetPanel(indexAddPhoto).GetView(1)
Dim MyCLV As CustomListView = pnl
Dim p As B4XView = Main.xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, allclv.AsView.Width, Activity.Height)
p.LoadLayout("ImageView")
Dim btm As Bitmap = LoadBitmap("ContentDir",uris.Get(j))
iv.Bitmap=btm
MyCLV.Add(p,"")
Next
End If
Return Null
End Sub
Sub StartActivityForResult(i As Intent)
Dim jo As JavaObject = GetBA
ion = jo.CreateEvent("anywheresoftware.b4a.IOnActivityResult", "ion", Null)
jo.RunMethod("startActivityForResult", Array As Object(ion, i))
End Sub
Sub GetBA As Object
Dim jo As JavaObject
Dim cls As String = Me
cls = cls.SubString("class ".Length)
jo.InitializeStatic(cls)
Return jo.GetField("processBA")
End Sub
I'll try to describe it in more detail to make it clearer. I have a CustomListView which contains a panel where the photo is displayed, as well as two buttons to add and take a photo. There will be about 10 such panels. I need the panel where the photos will be able to scroll horizontally and contain many photos. Also, if I click on the photo, I could delete it.
Last edited: