How to change startup activity?

Inman

Well-Known Member
Licensed User
Longtime User
I added a second activity (and a corresponding module) to my project and now I want to design and work on it only. When I hit F5, the emulator still shows the first activity. I know I can add a button or add a code in the Activity_Create of first activity, to load the second activity.

But is it possible not to load the first activity at all but instead load the second activity by default? On Visual Basic IDE, from the Project Properties menu, you can select the Startup Object, which is the form with which the project should start when it is executed. I was wondering if something like that is possible on B4A.
 

Inman

Well-Known Member
Licensed User
Longtime User
Thanks for the fast reply. Even though my next question is not connected to this topic, I dont want to create topics for each and every doubt.

Suppose there are 2 labels - lbl1 and lbl2 with the same Event Name lbl_click. Within lbl_click, is it possible to know which label the user clicked (lbl1 or lbl2)?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Actually it is better to create a new thread for each question. It helps other users find the information they are looking for.
Anyway, you can use the Sender object to get the view that raised the event.
B4X:
Sub lbl_click
 Dim lbl As Label
 lbl = Sender
 lbl.Color = Colors.Red
End Sub

You can use the Tag property to store any value you want (like a "name") and then retrieve it.
 
Upvote 0

Inman

Well-Known Member
Licensed User
Longtime User
Fantasic. I was desperately looking for this. Wonder if it is documented anywhere. If not, kindly split the last 2 posts on this thread to a new thread.
 
Upvote 0

Inman

Well-Known Member
Licensed User
Longtime User
The Main activity is always loaded first. You can change this behavior by editing the AndroidManifest.xml. However if you only need it for debugging I recommend you to call StartActivity(SecondActivity) from the main activity Activity_Create sub.

I finished the debugging part as you said. Could you please show an example as to how we can change the startup activity?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Do you want to always start with a different activity other than the "Main" activity?
The simplest solution is to copy the code of the startup activity to the Main activity module.

It can be changed by editing the AndroidManifest.xml file. However Basic4android assumes that the Main activity code runs first and you may encounter undesired results (I didn't realized it in my previous post).
 
Upvote 0

Inman

Well-Known Member
Licensed User
Longtime User
I started designing the app with an activity called "Main". Later I realised I need to make a different activity called "Timeline" as the first activity and when the user clicks a button on it I need to load the "Main" activity.

How do I do this?
 
Upvote 0
Top