Android Question [solved]HowTo add several DraggableViews by code


Active Member
Licensed User
Longtime User
I was able to use a DraggableView if the used View (in my case an ImageView) was added to the designer. What I'm trying to do is to add several DraggableViews by code, however I got stuck.

My Code so far:
Sub Globals
  Dim Cards As List 'shall hold the List of ImageViews
  Dim dvCards As List 'shall hold the List of draggableViews
End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("layoutMain") 'this layout is empty
Dim i As Int
Cards.Initialize 'initialize the List
dvCards.Initialize 'initialize the List
For i =0 To 20
   Dim ivCard As ImageView 'declare an ImageView, for each loop a new one!
   ivCard.Initialize("ivCard") 'intialize the ImageView
   Cards.Add(ivCard) 'add it to the List
   Dim dvCard As clDraggableView 'declare an DraggableView, for each loop a new one
   dvCards.Initialize(Activity,ivCard)'intialize the DraggableView
   dvCards.Add(dvCard) 'add it to the List
End Sub
The comments show what I tried to do. However I get an error in the line "dvCards.Initialize(Activity,ivCard)" (in German: "Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt." my translation: the Object was not set to an object-instance).
IMHO "Activity" is correctly set (I'm using it in the same way as when using the view that was added in the designer), so it has to be "ivCard", but WHY?
Last edited:


Active Member
Licensed User
Longtime User
Spelling problem!
The line "dvCards.Initialize(Activity,ivCard)" should have been "dvCard.Initialize(Activity,ivCard)".
However the with this change I get an error from within the DraggableView Class.

The line
  Activity.AddView(panel1, v.Left, v.Top, v.Width, v.Height)
from the .Initialze Sub raises the error "Error occurred on line: 14 (cldraggableview) - java.lang.NullPointerException"
Upvote 0