J jgm2 New Member Licensed User Longtime User Feb 12, 2014 #1 Hi I am producing an App that has a small icon to slide a menu in from the side on different sections. This contains multiple elements such as a search box, buttons, images and labels etc so I have decided to create a layout file and load it into a dynamically created panel. I have created a function in a code module to do this that uses the following: Code: Copy Dim Panel1 As Panel Panel1.Initialize("LeftMenuPanel") Activity.AddView(Panel1, 0, 0, PosX, 100%y) Panel1.LoadLayout("SlideNav") PosX being set to two thirds of the screen width. This works great up to now, however I want to run functions when buttons are being clicked on this layout and a few other things such as setting a custom font from a ttf so the menu is similar to an activity. I can have the click subs in each activity module that I run the menu from although this is copying code and doesn't seem like the best solution. It almost seems like I need 2 activities running at the same time taking up different parts of the screen although this doesn't seem to be possible. Can anyone tell me what the best way to produce this will be? Thanks for any help.
Hi I am producing an App that has a small icon to slide a menu in from the side on different sections. This contains multiple elements such as a search box, buttons, images and labels etc so I have decided to create a layout file and load it into a dynamically created panel. I have created a function in a code module to do this that uses the following: Code: Copy Dim Panel1 As Panel Panel1.Initialize("LeftMenuPanel") Activity.AddView(Panel1, 0, 0, PosX, 100%y) Panel1.LoadLayout("SlideNav") PosX being set to two thirds of the screen width. This works great up to now, however I want to run functions when buttons are being clicked on this layout and a few other things such as setting a custom font from a ttf so the menu is similar to an activity. I can have the click subs in each activity module that I run the menu from although this is copying code and doesn't seem like the best solution. It almost seems like I need 2 activities running at the same time taking up different parts of the screen although this doesn't seem to be possible. Can anyone tell me what the best way to produce this will be? Thanks for any help.
stevel05 Expert Licensed User Longtime User Feb 12, 2014 #2 Look at moving the code module to a class, then you can catch the events within the class and pass the appropriate subs to each activity with callsub. Or just control the menu from the class. It's difficult to give you an exact answer without knowing what the functions of the menu do. Upvote 0
Look at moving the code module to a class, then you can catch the events within the class and pass the appropriate subs to each activity with callsub. Or just control the menu from the class. It's difficult to give you an exact answer without knowing what the functions of the menu do.
Erel B4X founder Staff member Licensed User Longtime User Feb 13, 2014 #3 There are at least two or three libraries available that will help you with this: http://www.b4x.com/android/forum/pages/results/?query=sliding+menu&page=1&prefix=0 Upvote 0
There are at least two or three libraries available that will help you with this: http://www.b4x.com/android/forum/pages/results/?query=sliding+menu&page=1&prefix=0
J jgm2 New Member Licensed User Longtime User Feb 13, 2014 #4 I had already looked through the libraries available and I thought that because the styling and options will be so custom it may be best to look at making my own. It seems like using a class is a great option, think I missed the following from the class tutorial: "Classes store a reference to the context of the activity or service module that called the Initialize sub. This means that classes objects share the same life cycle as the service or activity that initialized them." It looks like I can access the objects from the layout after they have been loaded into the panel and handle click events from within the class. Controlling the menu from a class seems to work perfectly, thanks! Upvote 0
I had already looked through the libraries available and I thought that because the styling and options will be so custom it may be best to look at making my own. It seems like using a class is a great option, think I missed the following from the class tutorial: "Classes store a reference to the context of the activity or service module that called the Initialize sub. This means that classes objects share the same life cycle as the service or activity that initialized them." It looks like I can access the objects from the layout after they have been loaded into the panel and handle click events from within the class. Controlling the menu from a class seems to work perfectly, thanks!
Informatix Expert Licensed User Longtime User Feb 13, 2014 #5 jgm2 said: I had already looked through the libraries available and I thought that because the styling and options will be so custom it may be best to look at making my own. It seems like using a class is a great option, think I missed the following from the class tutorial: "Classes store a reference to the context of the activity or service module that called the Initialize sub. This means that classes objects share the same life cycle as the service or activity that initialized them." It looks like I can access the objects from the layout after they have been loaded into the panel and handle click events from within the class. Controlling the menu from a class seems to work perfectly, thanks! Click to expand... Did you look at my Sliding Sidebar class? Upvote 0
jgm2 said: I had already looked through the libraries available and I thought that because the styling and options will be so custom it may be best to look at making my own. It seems like using a class is a great option, think I missed the following from the class tutorial: "Classes store a reference to the context of the activity or service module that called the Initialize sub. This means that classes objects share the same life cycle as the service or activity that initialized them." It looks like I can access the objects from the layout after they have been loaded into the panel and handle click events from within the class. Controlling the menu from a class seems to work perfectly, thanks! Click to expand... Did you look at my Sliding Sidebar class?