Android Question calling a Class from within a Class to add UI element

Cableguy

Expert
Licensed User
Longtime User
Hi Guys...

I'm rusted!!!! I have a class dedicated to execute a web Login using a webview and jscript...
on page finished I want to call another class that will add an imageview to the current (main) activity...
I just can't seem to get it right...
 

thedesolatesoul

Expert
Licensed User
Longtime User
I usually have an AddToParent method in classes, that can add to a parent panel/activity directly. I prefer this approach because I want to build the layout top-to-bottom as I have to make sure all parents already have a parent. Sometimes my AddToParent just calls another/inner classes AddToParent.

Another way is to build your layout on a panel, and expose the Panel in AsPanel method. Then from the parent you can add it anywhere.

So either:
Activity->ClsA->ClsB

ClsA.AddToParent(Activity,w,x,y,z) <-clsA.AddToPArent will also call ClsB AddToParent

or

ClsA.BuildView <- This will have called ClsB.BuildView and returned on ClsA's panel
Activity.AddView(ClsA.AsPanel,w,x,y,z)
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Thanks for the suggestions guys.

I like your suggestion @thedesolatesoul ... Having that method in a class sure simplifies things...
Well, with my answered questions I have so far, I will surely have a lot of (re)coding to do!
 
Upvote 0
Top