Android Question Adding views to activity through class

Juzer Hussain

Active Member
Licensed User
Longtime User
Hi,

I have a requirement of adding a panel with text box to few forms to show help.
This panel is not added in layout.
I want to add it through a common class to avoid writing in every form. Is there a way for this.

Pls give some clue.

Thanks

Juzer
 

Brian Dean

Well-Known Member
Licensed User
Longtime User
I want to add it through a common class to avoid writing in every form. Is there a way for this.
This is quite easy to do. I usually add a semi-transparent panel over the activity - this dims the screen and stops the User activating any views. Then another panel on top of that carries the help information.

I am a bit busy at the moment, but if you are interested I can post a demo example later.
 
Upvote 0

Juzer Hussain

Active Member
Licensed User
Longtime User
Thanks Brian,

Actually i wanted to avoid adding any view to layouts.
Looks like it isn't possible to add everything from class.

I will also add a panel(in every layout) and add a panel over it from class to show help text.

Thanks
Juzer
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
Actually i wanted to avoid adding any view to layouts.
I don't add any views to the layout - the class creates the panel. It certainly is possible to add everything from a class! Are you interested now?
 
Upvote 0

Juzer Hussain

Active Member
Licensed User
Longtime User
After getting value in class (from the job) I am loading a predefined layout in a temporary panel.
When i am trying to add this temp panel to activity it gives error.
 
Upvote 0

Juzer Hussain

Active Member
Licensed User
Longtime User
error in below line
java.lang.ClassCastException: java.lang.Class cannot be cast to anywheresoftware.b4a.BALayout
B4X:
sModule.AddView(tmpPanel,0,0,10%x,10%y)
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
Here is the demo. This one gives short help tips with "Got it" (don't show again) and "Later" (don't bother me now) options. I have added a "Reset" button to set everything back to the start - this is useful for the demo.

If you want to give longer help messages then you will have to adapt the demo to provide a larger area for text. However the principle of overlaying a panel to screen the underlying activity will be the same. Note that you need to give the panel some elevation to get above buttons. Let me know if anything is unclear.
 

Attachments

  • HelpDemo.zip
    10.9 KB · Views: 136
Last edited:
Upvote 0

Juzer Hussain

Active Member
Licensed User
Longtime User
I checked the demo and found a minor difference instead of Me it should be Activity when calling class function . I changed it and it worked.
Lot of Thanks Brian.

Juzer
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…