Need Some General Help for Android Programming

Movado

Member
Hey Guys,

I recently started developing applications for android and stumbled upon Basic4Android. I took a course a few years ago for visual basic and the code is similar and easy to learn. I have a few general questions though.

1) How to you program a button to exit or quit the application? For example:
B4X:
Sub Button1_Click
    'code that closes application
End Sub

2) How do i switch between multiple layouts. For example, i have layout1 open with the application and when a button is clicked, it switches to layout2.

3) How do i set the background of a layout to a picture and does it need to be a specific format?

I know they are really easy questions but your help is much appreciated, thanks!

(Sorry for putting in wrong section!)
 
Last edited:

James Moxham

Member
Licensed User
Longtime User
I'm still learning this too. In answer to 1, I think it is
B4X:
   activity.finish ' close the program

I'm pretty sure 2 has been answered on this forum recently. Someone will hopefully chime in soon with the answers to 2 and 3.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
First I recommend you to start with the tutorials listed here: Basic4android - Android programming with Gui designer
2) You can use multiple activities or you can load the layout to a panel and add the panel to the activity. Then you can remove the panel. Create a new one and load the second layout to this panel.
3) In the designer you should add an image (all popular types supported) to the Images List, then change the activity Drawable to BitmapDrawable and choose the image.
 
Upvote 0

Movado

Member
Thanks i will try the code out to close the program. And thanks Erel for the info on added pictures, i figured out how to change between layouts as well. Do you know how i can, by pressing a button open another application installed on my phone, specifically when the button is pressed Google Maps opens up?
 
Last edited:
Upvote 0

mramos

Member
Licensed User
Longtime User
Movado

Here is a test to run webview, if you load it in a panel and display it with an exit button (that flip visible true and false), you will have what you want.
 

Attachments

  • webviewtest.zip
    5.5 KB · Views: 215
Upvote 0

Movado

Member
Here is a test to run webview, if you load it in a panel and display it with an exit button (that flip visible true and false), you will have what you want.

Thanks, i changed it up a bit but it worked :p Is there any way i can call the button to open an application already installed on my phone though, the Google Maps App so it doesn't need to work through a webview?
 
Upvote 0

mramos

Member
Licensed User
Longtime User
Oh okay. I am using the trial atm so if i upgrade to full version i will be able to do this. Thanks

Should be able to do this on the trail I would think.

In the far right pane there is tabs at the bottom, click libraries and you should see the one Erel mentions (Phone), just check it on.


Erel, I think I have the new version at home, will check tonight. Hope it fixes it, I really like your compiler a lot. Can not do much at work Thanks
 
Upvote 0

James Moxham

Member
Licensed User
Longtime User
I'd recommend getting the full version. I'm a bit of a cheapskate buying stuff, particularly on the internet, but I also know a bargain when I see one, and Basic4Android is a bargain.

How many languages are there where you can request something and the author implements it the next day? That has happened twice in the last week (thanks Erel!).

I look at the price of an apple ipad and it is still a lot more than the cost of an Android plus Basic4Android.

Just my 2c worth FWIW.
 
Upvote 0
Top