Getting Parent

roarnold

Active Member
Licensed User
Longtime User
I am trying to get the parent of the, Parent/Child, problem. I found this I think by Erel but I get an error on it:

B4X:
Sub GetParent(v As View) As View
    Dim r As Reflector
    r.Target = v
    Return r.RunMethod("getParent")
End Sub

It errors on "r.Target = v"

Any ideas,

Thx Ron
 

stevel05

Expert
Licensed User
Longtime User
What error do you get?

-------------------
Sent via Tapatalk
 
Upvote 0

roarnold

Active Member
Licensed User
Longtime User
Hey Steve,

Received it on Target.

I have enclosed the zip file so you can see what I have done and I have commented the error received.

Appreciate it, Ron
 

Attachments

  • OBR VIEW ISSUE.zip
    63.9 KB · Views: 175
Upvote 0

stevel05

Expert
Licensed User
Longtime User
You are trying to get the parent of an uninitialized view.

B4X:
Sub EditText_EnterPressed
'Dim p As Phone
'p.HideKeyboard(Activity)

Log("pressed")
      Dim v As View
      v=Sender                    'You probably want this line or similar
      Dim Mode As String
      Dim Visible As Boolean
      Log(GetParent(v))        'You need to assign the result to something!
   '   ToggleViewVisibility(Mode, Visible)
   
   deleteview
   
      Activity.RemoveView

I'm not sure without going through the whole thing what you are trying to do and if the rest will work, but this will get you past this issue. There are more errors, post another question if you need to.
 
Upvote 0

roarnold

Active Member
Licensed User
Longtime User
View Issue

Steve,

I have stripped out all the attempts I made to solve the Parent/Child issue. Your previous post still errors on line 293.

That area, lines 277 - 308, is to be a popup panel for the Doc to select a response to the previously selected label.

I have tried most everything. So now you see the module as it was originally coded. When you compile it the IDE will present a HSV with eight items. Click a right side box and hit the Enter Key.

The error will tell you that the Parent already has a child, must Removeview().

Thanks,
Ron
 

Attachments

  • OBR VIEW ISSUE.zip
    63.5 KB · Views: 177
Upvote 0

stevel05

Expert
Licensed User
Longtime User
B4X:
Sub EditText_EnterPressed

   
      
      Dim pnl14 As Panel
         pnl14.Initialize(pnl14)
      Dim cld As ColorDrawable
       cld.Initialize ( Colors.RGB( 173, 216, 230) , 5dip )
       pnl14.Background = cld 
      Activity.AddView(pnl14, 80dip, 90dip, 170dip, 180dip)
      
   
      lblnormal.Initialize("lblnormal")
        lblnormal.Text = "Normal"  & "√"
      lblnormal.TextColor = Colors.Black
        lblnormal.TextSize = 10
      Activity.AddView(pnl14, 80dip, 100dip, 100dip, 40dip)
      
      lblabnormal.Initialize("lblabnormal")
        lblabnormal.Text = "abnormal" & "√"
      lblabnormal.TextColor = Colors.Black
        lblabnormal.TextSize = 10
      Activity.AddView(pnl14, 80dip, 130dip, 100dip, 40dip)
   
      lblna.Initialize("lblna")
        lblna.Text = "N/A" & "√"
      lblna.TextColor = Colors.Black
        lblna.TextSize = 10
      Activity.AddView(pnl14, 80dip, 160dip, 100dip, 40dip)
      

End Sub

You are trying to add the view pnl14 to the Activity 4 times.

B4X:
Activity.AddView(pnl14, 80dip, 160dip, 100dip, 40dip)

You can only add each view once. Therefore the system is telling you that you have already added the view to a parent.
 
Upvote 0

roarnold

Active Member
Licensed User
Longtime User
Oofff,

Well, I guess I figure out how to solve this another way. Those three options are needed in a popup for the app. This is a limitation I guess.

Could I add pnl14 with the first option, then add a panel to the original pnl14 for the second option, something like that?

Appreciate your help Steve,
R
 
Upvote 0

roarnold

Active Member
Licensed User
Longtime User
Steve.

Got it. Used pnl14.addview and replaced pnl14 inside the (..........) to the label name.

Rock on,

Thanks for all you input,
Ron
 
Upvote 0
Top