Android Tutorial Any threads just for newbies?

Just getting started with BA4 and am very confused. I don't understand many terms and terminology. Have next to no experience with Java though am reasonably proficient with Basic.

A friend sent me a YouTube link to getting started and that's been helpful. I was able to get the emulator up and running. When I tried "Hello World" again tonight, I now get a Java FileNotfound error (1.bal) in the emulator.

Tried searching the forum but get overwhelmed with results. Are there any threads that just handle getting started newby questions? I tried a bunch of "beginner" & "tutorial" threads but they all seem to quickly evolve into more advanced techniques I am lost before I can even get started.

I'm excited about getting started programming for Android. TIA for any help.

Swede
AOU - Swede's Dock in Lovely Lavallette, NJ - home of Gösta H. Lovgren. Anal Orifi Unwanted
 

Swede

Member
Licensed User
Longtime User
This is an error in the source code.
Click on the Files in the lower right corner in the IDE.
Click on mainwithkeyboard.bal
And click the button 'Remove Selected'.

This will be corrected in the next update.

Best regards.

Worked like a charm. Thanks, Klaus.

Now to find out what's wrong with my version {sigh}.
 

Swede

Member
Licensed User
Longtime User
What line is line 45 ?

It would be easier to help you if you posted the whole project as a zip file (IDE menu Files / Export As Zip)
so we see what you have done and how. Too often the error is not where you think it is but somewhere else.

Best regards.

Done (I hope).

Thanks
 

Attachments

  • Swede01.zip
    7 KB · Views: 289

Roger Garstang

Well-Known Member
Licensed User
Longtime User
Also, delete the empty Sub Btn_Action_Click at the bottom and name the real one Sub Btn_Action_Click. Then you just need to add code for the New button click and you are set. The Event Name in the Designer for your button is what you call your Prefix for your Event Subs- (To create new Event Subs) When you type Sub then hit space it tells you to hit tab, so hit tab then find your desired type of event. Type the Event Name from your button in the Green Box and hit enter. (You can also create event stubs in the designer when you create the variables for the views using Generate Members).
 
Last edited:

Swede

Member
Licensed User
Longtime User
Line 45- Btn_Action.Text = "N E W"

Did the job. Thx Roger

Also, delete the empty Sub Btn_Action_Click at the bottom and name the real one Sub Btn_Action_Click.
Done, and compile successfully. As for the rest:
`
Then you just need to add code for the New button click and you are set. The Event Name in the Designer for your button is what you call your Prefix for your Event Subs- When you type Sub then hit space it tells you to hit tab, so hit tab then find your desired type of event. Type the Event Name from your button in the Green Box and hit enter.

I'll get to work on it and be back {grin}. Thanks all.
 

Swede

Member
Licensed User
Longtime User
Okay, got sidetracked with another project(s), but am back to spend some time with B4. (hopefully all summer). Have updated to B4 2.00 (thanks to support who were quick to respond when I had a minor problem).

Here's my first example code. It compiles and installs fine.Even runs a little {grin}

emulator_01.jpg


However, when click the button, it changes to "New" but that's all. It doesn't replace the keyboard underneath. Clicking a back button clears the keyboard and shows the congratulatory msg for answering such a tough problem. But I don't get a new problem.

emulator_02.jpg



The problem is mine in that I don't yet get the event oriented programming (I think)


B4X:
'B4 2.00
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.

End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.

   Dim btn_Action As Button
   Dim edt_Result As EditText
   Dim LblComments As Label
   Dim lblMathSign As Label
   Dim lblNumber1 As Label
   Dim lblNumber2 As Label
   Dim Number1, Number2 As Int
End Sub

Sub Activity_Create(FirstTime As Boolean)
  Activity.LoadLayout("Main")
  New
End Sub
Sub New
  Number1 = Rnd(1, 10)
  Number2  = Rnd(1,10)
  lblNumber1.Text = Number1
  lblNumber2.Text = Number2
  LblComments.Text="Enter the Result" & CRLF & "Click on OK"
  edt_Result.Text = ""
End Sub
Sub btn_Action_Click
  If btn_Action.Text = "O K" Then
     If edt_Result.Text = "" Then
       Msgbox(" No result Entered", "E R R O R")
      Else 
       Check_Result   
    End If
   Else
      New
     btn_Action.text = "O K"
  End If
End Sub
Sub Check_Result
   If edt_Result.Text = Number1 + Number2 Then
      LblComments.Text = "G O O D Result" & CRLF & "Click on New"
     btn_Action.Text = "N E W"
    Else 
     LblComments.Text = "B U M M E R"  & CRLF & "Enter a new result" & CRLF & "and Click OK"
   End If
End Sub
 
Last edited:

stevel05

Expert
Licensed User
Longtime User
Once you've checked the result you need to call your sub 'New' again to set a new problem.
 

Roger Garstang

Well-Known Member
Licensed User
Longtime User
A Few options-

1. Add IME Library and use it to hide keyboard when you process the button click.

2. IME Library also allows you to request notification of height changes when it comes out. Could use that event to move your views up to keep them in view.

3. Use a Scrollview so you can scroll your other views up and see them...usually needs #2 to size your scrollview smaller so it scrolls.
 

Roger Garstang

Well-Known Member
Licensed User
Longtime User
What stevel05 said too. For some reason I thought your main question was concerning the keyboard covering up your result because when you clicked the button it didn't go away. Your New Sub may also need something setting focus to your EditText View so you can type and it will open the keyboard back up too. You can either make the New Problem occur automatic in the Result Check or modify the if in your button click to check for button text being "N E W" and processing it. Could also use a Select Case in your button click event to test for what button text to process for.
 
Last edited:

klaus

Expert
Licensed User
Longtime User
Have a look at page 30 in the Beginner's Guide and compare the btnAction_Click routine.with yours.
For your information you got all the sorce codes for the programs in the Beginner's Guide to compare with your code.
Be careful in the spelling you use Btn_Action and btn_Action.

Best regards.
 

Swede

Member
Licensed User
Longtime User
Once you've checked the result you need to call your sub 'New' again to set a new problem.
Thanks Steve. I'll get the hang of it one day. It works now (sort of, see below)

1. Add IME Library and use it to hide keyboard when you process the button click.

2. IME Library also allows you to request notification of height changes when it comes out. Could use that event to move your views up to keep them in view.

3. Use a Scrollview so you can scroll your other views up and see them...usually needs #2 to size your scrollview smaller so it scrolls.

Don't know what an IME library is (yet), nor how to load one. Expect that's down the road for me right now. Still in kindergarten here. {sigh}


For some reason I thought your main question was concerning the keyboard covering up your result because when you clicked the button it didn't go away. Your New Sub may also need something setting focus to your EditText View so you can type and it will open the keyboard back up too. You can either make the New Problem occur automatic in the Result Check or modify the if in your button click to check for button text being "N E W" and processing it. Could also use a Select Case in your button click event to test for what button text to process for. For some reason I thought your main question was concerning the keyboard covering up your result because when you clicked the button it didn't go away. Your New Sub may also need something setting focus to your EditText View so you can type and it will open the keyboard back up too.

Well Roger, I was concerned about the keyboard covering up the label. Clicking the back button made it disappear (and showed the label), and it never came back. What command makes it appear/disappear? Hmm Settin Focus. Haven't gotten that far yet. Later on in my education. (most is, I know).

Have a look at page 30 in the Beginner's Guide and compare the btnAction_Click routine.with yours.
For your information you got all the sorce codes for the programs in the Beginner's Guide to compare with your code.
Be careful in the spelling you use Btn_Action and btn_Action.
Just what I did Klaus and it's working now. {finally}. However I'm having a problem. It compiles in 1.92 but not in 2.00. Get a
Compiling generated Java code. Error
javac 1.6.0_26
src\ba4\my_first_program\main.java:54: cannot find symbol
symbol : variable sharedProcessBA
location: class anywheresoftware.b4a.BA
processBA.sharedProcessBA.activityBA = null;
^
error. Do I need to change paths or something? Have 1.92 & 2.00 in different subfolders (both under Android)?

Thanks all answers, and patience.
 

stevel05

Expert
Licensed User
Longtime User
Take a look here, I think this is the same issue.
 

Swede

Member
Licensed User
Longtime User
Take a look here, I think this is the same issue.

Sorry, Steve. I'm exceptionally dense. Nothing there that I saw helped me. I checked the paths (under Tools/Configure paths) against 1.92 (where it compiles fine) and they appear to be (exactly) the same.

(Suggestion for next update - Put the version number in the title. I keep having to click the about button to see which version I'm in. Of course once I get 2.00 running, I'm unlikely to ever again use 1.92, but still ...)
 
Last edited:

Swede

Member
Licensed User
Longtime User
Oops!

I just noticed in the title at the top of the thread:

Basic4android Getting started & Tutorials Android development starts here. Please do not post questions in this sub-forum.


Should I move to another sub-forum?
 

Swede

Member
Licensed User
Longtime User
Hi Klaus, am stuck again. I'm not an inexperienced programmer, just that I've never really worked with a designer before. Always rolled my own screen. I remember the layout when I fooled with VB(2?) years ago, then got hooked on PNWin. PB has several designer pkgs I believe are pretty good but I never liked using them.

Okay, that out of the way, I'm on pg 40 where it says to make the keyboard. I've got btn0 okay and it saying to create the other buttons.

emulator_03.jpg

See how the resize handles are around the btn0. How do I remove them? If I click elsewhere the btn property screen changes.

The instructions say "Change the following parameters" and when I do it, no second button appears. The first btn just changes it's name.

I know it's just something simple but I'm even simpler I guess.

Thx.

PS, how do I delete a control (button)? I see now delete anywhere.
 
Last edited:

Swede

Member
Licensed User
Longtime User
Thanks, Klause. Obviously I used it before but forgot.

Okay Got everything done okay. I got the "second" program to run but nothing happened {sigh}. It displayed in the emulator okay, but no activity ... {arrgh}

So I went over it line by line comparing with the "second" example in the Source Code folder. Found a couple little things, some empty Subs I had deleted. Now my "second" is letter for letter with the "second" example.
Compiles fine but won't run in the emulator:
error_01.jpg

Am using 1.92 as I was getting same/similiar error with 2.00 every time whereas 1.92 would work, at least with my sorry attempts at code, but not if I use example code.

Here's the zipped code: http://swedesdock.com/aa_temp/Swede_Second.zip

Thanks your help
 

klaus

Expert
Licensed User
Longtime User
The problem is that you didn't make the changes on page 35 in the Beginner's Guide replace the EditText view edtResult by a Label lblResult !
You made the change only in the code.
When you see the error message 'Object should first be initialized' that means that the given object was not declared in a Dim statement or doesn't exist in a layout file.

Best regards.
 

Swede

Member
Licensed User
Longtime User
Thanks your patience Klaus. My problem lies mostly in that I am unfamiliar with working with a Designer. The concept is not easy for me to grasp.

For example I was drawing on an emulator started by the tools/AVD mgr. I see the example emulater when I load Designer but don't know how to connect it to the designer. Double Clicking the connect gets a No device found" msg, so I run the AVD mgr. That emulator is bigger than the one that loads with designer (that I can't reach)

I have the mySecond.b4a code EXACTLY matching the example G:\Basic4android\Documentation\Beginners Guide\SourceCode\SecondProgram\SecondProgram.b4a

Yet when I run it, none of the buttons work. {sigh}

This is a VERY frustyrating experience but I'm committed (at least for now).

One problem for me is I have no computer training and don't understand the concept of terms like "Classes" & "Objects" mean and get confused. It's like when I first started with Windows programming (coming from Dos). Once I got it clear in my mind the difference between Dialogs, Controls and Windows, I started making progress but t was slow going for months.

Designers frustrate me (rather roll my own) but I guess a designer is necessary here so I'll have to get used to it.

Thanks your patience Klaus (and all others too).

Here's everything zipped if any care to look. {sigh}


http://swedesdock.com/aa_temp/Swede_Second_02.zip
 

Attachments

  • Swede_Second_02.zip
    7.7 KB · Views: 249
Top