I cant figure this out. I have spent at least 2 hours.
I keep on gettinng "java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setNavigationMode(int)' on a null object reference"
I am trying to implement an action bar with the standard actionbar. I copied the code from the example but when it gets to:
It gives the above error.
I clearly initialized bar in the line before:
Thanks.
below is all the code from the project:
I keep on gettinng "java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setNavigationMode(int)' on a null object reference"
I am trying to implement an action bar with the standard actionbar. I copied the code from the example but when it gets to:
B4X:
bar.NavigationMode = bar.NAVIGATION_MODE_STANDARD
It gives the above error.
I clearly initialized bar in the line before:
B4X:
bar.Initialize("bar")
Thanks.
below is all the code from the project:
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim UDPSocket1 As UDPSocket
Public Confirmation = False As Boolean
Public ison As Boolean
Public pa As String
Public Timer3 As Timer
Public cssid As String
Public timeout = False As Boolean
Public ii = 0 As Int
Dim w1 As WiFiConnect
Private NM As JavaObject
Public csu As CallSubUtils
Dim alarmHours, alarmMinutes As Int
Dim edit As Boolean = False
Dim tag As Int
Dim checkbox As List
Private currentTab As Int
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.
Private Button2 As Button
Private Button3 As Button
' Private Button1 As Button
Dim ScrollView1 As ScrollView
Dim pnl(10) As Panel
Dim pan As List
Dim del(10) As Button
Dim dele As List
Dim checkbox1 As CheckBox
Private Button1 As Button
Private NS As Label
Private del_files As Button
Private Label1 As Label
Private updaten As Button
Dim bar As StdActionBar
Private panel1, panel2, panel3 As Panel
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
If FirstTime Then'
UDPSocket1.Initialize("UDP", 2945, 8000)
End If
If FirstTime = True Then
Timer3.Initialize("Timer3", 10000)
End If
pan.Initialize
dele.Initialize
bar.Initialize("bar")
bar.NavigationMode = bar.NAVIGATION_MODE_STANDARD 'change to list to see the other mode
bar.SetListItems(Array As String("Dropdown 1", "Dropdown 2", "Dropdown 3"))
bar.Subtitle = "This is the subtitle"
bar.ShowUpIndicator = True
Activity.Title = "This is the title"
Activity.AddMenuItem3("MenuItem", "mi", LoadBitmap(File.DirAssets, "ic_small.png"), True)
panel1.Initialize("")
panel2.Initialize("")
panel3.Initialize("")
bar.AddTab("Tab 1").Tag = panel1
bar.AddTab("Tab 2").Tag = panel2
If bar.NavigationMode = bar.NAVIGATION_MODE_TABS Then
'Add icon to tab 3
Dim tb As StdTab = bar.AddTab("Tab 3")
tb.Tag = panel3
Dim bd As BitmapDrawable
bd.Initialize(LoadBitmap(File.DirAssets, "ic_small.png"))
tb.Icon = bd
'set the current selected tab
bar.SelectedIndex = currentTab
If currentTab = 0 Then bar_TabChanged(currentTab, bar.SelectedTab)
End If
Activity.LoadLayout("test2")
refresh
End Sub