S Sanxion Active Member Licensed User Longtime User Dec 3, 2015 #1 Hi all I am attempting to enumerate all the panels with a specific tag in a layout and then center them with the following: ' Center all the lesson panels For Each pnl As Panel In Activity Dim PanelTag As String PanelTag = pnl.Tag If PanelTag.SubString2(0,5) = "Lesson" Then pnl.Left = (Activity.Width - pnl.Width) / 2 pnl.Top = (Activity.Height - pnl.Height) / 2 End If Next However, the following error is occurring: java.lang.ClassCastException: android.widget.ImageView cannot be cast to android.view.ViewGroup Any ideas?
Hi all I am attempting to enumerate all the panels with a specific tag in a layout and then center them with the following: ' Center all the lesson panels For Each pnl As Panel In Activity Dim PanelTag As String PanelTag = pnl.Tag If PanelTag.SubString2(0,5) = "Lesson" Then pnl.Left = (Activity.Width - pnl.Width) / 2 pnl.Top = (Activity.Height - pnl.Height) / 2 End If Next However, the following error is occurring: java.lang.ClassCastException: android.widget.ImageView cannot be cast to android.view.ViewGroup Any ideas?
eurojam Well-Known Member Licensed User Longtime User Dec 3, 2015 #2 you can loop trough all the views in your activity and check if it is a panel like this: Code: Copy For Each v As View In Activity If v Is Panel Then Dim PanelTag As String PanelTag = v.Tag If PanelTag.SubString2(0,5) = "Lesson" Then v.Left = (Activity.Width - v.Width) / 2 v.Top = (Activity.Height - v.Height) / 2 End If End If Next Upvote 0
you can loop trough all the views in your activity and check if it is a panel like this: Code: Copy For Each v As View In Activity If v Is Panel Then Dim PanelTag As String PanelTag = v.Tag If PanelTag.SubString2(0,5) = "Lesson" Then v.Left = (Activity.Width - v.Width) / 2 v.Top = (Activity.Height - v.Height) / 2 End If End If Next
LucaMs Expert Licensed User Longtime User Dec 3, 2015 #3 eurojam said: you can loop trough all the views in your activity and check if it is a panel like this: Code: Copy For Each v As View In Activity If v Is Panel Then Dim PanelTag As String PanelTag = v.Tag If PanelTag.SubString2(0,5) = "Lesson" Then v.Left = (Activity.Width - v.Width) / 2 v.Top = (Activity.Height - v.Height) / 2 End If End If Next Click to expand... [off topic] If PanelTag.SubString2(0,5) = "Lesson" Then If PanelTag.SubString2(0,6) = "Lesson" Then You can use: If PanelTag.StartsWith("Lesson") Then Last edited: Dec 3, 2015 Upvote 0
eurojam said: you can loop trough all the views in your activity and check if it is a panel like this: Code: Copy For Each v As View In Activity If v Is Panel Then Dim PanelTag As String PanelTag = v.Tag If PanelTag.SubString2(0,5) = "Lesson" Then v.Left = (Activity.Width - v.Width) / 2 v.Top = (Activity.Height - v.Height) / 2 End If End If Next Click to expand... [off topic] If PanelTag.SubString2(0,5) = "Lesson" Then If PanelTag.SubString2(0,6) = "Lesson" Then You can use: If PanelTag.StartsWith("Lesson") Then
S Sanxion Active Member Licensed User Longtime User Dec 3, 2015 #4 Thank-you for both contributions! A pleasure as always. Upvote 0