[BUG] Beta 2.50, possibly...

eps

Expert
Licensed User
Longtime User
I think this is probably something I've missed out, in updating in getting to 2.50, I was on 2.20 or 2.30 before.. From 14 Oct 2012...

I've tried regenning code, and it failed, with the Tabhost Dim.. I tried the Tutorial code - that doesn't work either - I get the following problem when the code executes (either my code or the Tutorial - both have the same Null Pointer Exception). Any thoughts? I'm sure it's a problem with my setup, but I can't seem to work out what.

B4X:
main_activity_create (B4A line: 26)


TabHost1.AddTabWithIcon ("Name", bmp1, bmp2, "page1") 'load the layout file of each page
java.lang.NullPointerException


   at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:91)
   at anywheresoftware.b4a.objects.TabHostWrapper.createPanelForLayoutFile(TabHostWrapper.java:115)
   at anywheresoftware.b4a.objects.TabHostWrapper.AddTabWithIcon(TabHostWrapper.java:157)
   at anywheresoftware.b4a.samples.tabhost.main._activity_create(main.java:253)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
   at anywheresoftware.b4a.samples.tabhost.main.afterFirstLayout(main.java:85)
   at anywheresoftware.b4a.samples.tabhost.main.access$100(main.java:16)
   at anywheresoftware.b4a.samples.tabhost.main$WaitForLayout.run(main.java:72)
   at android.os.Handler.handleCallback(Handler.java:587)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:123)
   at android.app.ActivityThread.main(ActivityThread.java:3683)
   at java.lang.reflect.Method.invokeNative(Native Method)


   at java.lang.reflect.Method.invoke(Method.java:507)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
   at dalvik.system.NativeStart.main(Native Method)
java.lang.NullPointerException

I am using javac.exe : C:\Program Files\Java\jdk1.6.0_26\bin\javac.exe

android.jar : C:\Android\android-sdk\platforms\android-16\android.jar

I'm guessing it's something to do with my outdated libraries, but have attempted to keep my code as widely useable as possible, by as many Android devices.

Happy to supply any further information if it will help to work out what the problem is.

:sign0163:

ETA : I've updated to JDK 1.7 - no difference. I rebuilt some other code I have, no Tabhosts, this works fine. So maybe it is a bug??
 
Last edited:

eps

Expert
Licensed User
Longtime User
You were on 2.2 before. This behaviour changed in 2.30.
Now you need to add the tab host to the activity before you add a layout to it.

Sent from my GT-I9000 using Tapatalk 2


Cheers, I'll update and see if this works, which I'm sure it will.
 

eps

Expert
Licensed User
Longtime User
Hmm... I'm still missing something..

From the Tutorial I had :

B4X:
   Activity.LoadLayout("main")
   Dim bmp1, bmp2 As Bitmap
   bmp1 = LoadBitmap(File.DirAssets, "ic.png")
   bmp2 = LoadBitmap(File.DirAssets, "ic_selected.png")
   
   TabHost1.AddTabWithIcon ("Name", bmp1, bmp2, "page1") 'load the layout file of each page
   TabHost1.AddTab("Color", "page2") 
   TabHost1.AddTab("Animal", "page3")

Then I changed it to :

B4X:
   Activity.LoadLayout("main")
   Dim bmp1, bmp2 As Bitmap
   bmp1 = LoadBitmap(File.DirAssets, "ic.png")
   bmp2 = LoadBitmap(File.DirAssets, "ic_selected.png")
   
    TabHost1.Initialize("TabHost1")
    Activity.AddView(TabHost1, 0, 0, 300, 430)
   
   TabHost1.AddTabWithIcon ("Name", bmp1, bmp2, "page1") 'load the layout file of each page
   TabHost1.AddTab("Color", "page2") 
   TabHost1.AddTab("Animal", "page3")

But this still gives the same error...

:BangHead:
 

klaus

Expert
Licensed User
Longtime User
To me it looks like a bug, tested with B4A 2.50 Beta2.
I get the same error as you.
It works with B4A V2.30

I made a very simple test project from scratch.
With a Main layout with just the TabHost
And a second layout Page1 with a Label and Button
Same error at line TabHost1.AddTab("Page 1", "Page1").
No difference if the TabHost is added with a layout file or added in the code.
B4X:
Sub Globals
    Dim TabHost1 As TabHost
End Sub

Sub Activity_Create(FirstTime As Boolean)
'    Activity.LoadLayout("Main")
    
    TabHost1.Initialize("TabHost1")
    Activity.AddView(TabHost1, 0, 0, 100%x, 100%y)
    
    TabHost1.AddTab("Page 1", "Page1")
End Sub
Best regards.
 

Attachments

  • TabHost1.zip
    7.9 KB · Views: 206

eps

Expert
Licensed User
Longtime User
Agreed, I've installed 2.30 and we're back in business. So looks like a bug in 2.50.

 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…