Screen Change

roarnold

Active Member
Licensed User
Longtime User
I was wondering about screen changes to say I would like the input (EditTexts and button) screen to be portrait and the result (ImageViews, Labels) screen to be in landscape. I worked with designer and it appears that I can only have one or the other?

Thanks,
R
 

NJDude

Expert
Licensed User
Longtime User
In the IDE you set the orientation for the whole app/project, however, you can change the orientation of individual activities by adding the following line to the AndroidManifest using the Manifest editor.

e.g. Let's say your project is setup in portrait mode but you want the activity called "MyOutput" to be landscape.
B4X:
SetActivityAttribute(MyOutput, android:screenOrientation, "landscape")
 
Upvote 0

roarnold

Active Member
Licensed User
Longtime User
Right on Sir. The reading I did to find an answer mentioned not to edit the manifest file but I can do that. Cool. Thank You Kindly. R
 
Upvote 0

roarnold

Active Member
Licensed User
Longtime User
Almost, but this is probably another learning experience. NJDude, I have a second activity defined in designer when I edited the manifest file it indeed oriented the main activity as I wished but it also impacted the other activity, logo. So here is my question. Should I have defined a second activity as another Module? That would give me module "Main" which shows in the upper left of the app bar under File and Edit and probably another module next to it for my second activity as opposed to being defined in designer only?

Could explain why I had to jump through hoops to initialize imageviews, lol.

Thanks in advance.
R
 
Upvote 0

roarnold

Active Member
Licensed User
Longtime User
NJDude, what I have is essentially one large activity module, couple hundred lines of code. I have the first screen that contains three EditText items and a button. The other screen is nothing more than a display screen of the data being requested by the individual. It never occurred to me that I should have made two activity modules one for each screen which would allow me to have the two different presentations (landscape and portrait) but more importantly allow for managing the code a bit better.

Its all good, your post on the manifest addition was a huge help. I had originally built this in eclipse about ninety percent of it anyway before finding out about B4A.

I will let you know how it turns out.

Thanks for the assist!
R
 
Upvote 0

roarnold

Active Member
Licensed User
Longtime User
NJDude,

I tried the two activities as mentioned but I believe I read that variable can't be passed between them (2007 stuff on the board I was reading)? The first activity at the end needs to call a sub named process (info) passing a string from activity calling sub to the sub in activity two. I could not get the data in there.

I have another option I nope that won't work. I was thinking I could place the get and parse in activity two but then I would essentially be back to one activity.

Hmm, any idea how to pass a string from one activity to another?

Appreciate the help, Sir.
R
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
You can create Process_Globals variables in both Activities. These Process_Globals can be accessed by each Activity. Store your information in these variables and access them from the other Activity.

Say your main activity has a variable named myvarmain. When your second activity loads, you can access this information like:

newvar = main.myvarmain

Say you 2nd activity is named maintwo and you then set a value in the second activity in a process_global variable, when you return to the main activity you can access it like:

mynewvar = maintwo.myvarname
 
Upvote 0

roarnold

Active Member
Licensed User
Longtime User
Hi, thank you for that help. It wouldn't need a lib ref would it? Just asking as I got an error on the call to the second activity. Although it very well could be my lib location, checking that now.

Appreciate the help.
R
 
Upvote 0

roarnold

Active Member
Licensed User
Longtime User
Hi Margret,

Works well and curious about something with respect to the variables. When I run debugger and made the transition to the second activity - via Start Activity(Main1) - I noticed that when I got at the Activity Create in the second activity a variable or placeholder named MAIN cropped up at the global variable location in debugger with a [and all my variables that I set in the Main Activity] into the second activity.

I guess that this must have been accomplished by a library? As I only set one variable to pass the results from a JSON string return from the MySQL db.

Anyway, it looks to be working.

Thanks Again for the assistance.
R
 
Upvote 0
Top