Android Question TabStrip w/extentions - Tab Removal

AKJammer

Active Member
Licensed User
I'm transitioning a portion of my application from B4J over to B4A. Some users will be using a 7" android tablet to make entries into the database, but the entry screens that each user will see can be different. In addition, every half hour or so, a different user will be using the tablet, so I need to be able to reset the screen and reconfigure, based on a spinner choice. All that said, I've been reading the forums trying to determine the best type of Tab mechanism to use. I started with TabHost, but couldn't get the tab removal to work, then moved over to TabStrip. TabStrip itself doesn't have the removal capability so I added the TabStripViewPagerExtendet that was created by Alexander Stolte.

After creating the tabstrip in designer (as thScores) and adding the items in globals
B4X:
     dim tse as TabStripViewPagerExtendet

The first time through it works fine
B4X:
    thScores.LoadLayout("tabJJFinal", "Finals")
    
    If isChiefJudge Then
        thScores.LoadLayout("tabJudges", "Judges")
    End If

After hitting the reset button it goes through here and works
B4X:
    Dim tbList As List = tse.GetAllTabLabels(thScores)    
    For i = 0 To tbList.Size - 1
        tse.RemovePage(thScores, 0)    ' Always removing tab 0, they get deleted along the chain
    Next

But when I go back to add the tabs again for the next user
B4X:
    thScores.LoadLayout("tabJJFinal", "Finals")    '  this is line 286

it blows up:

B4X:
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
Error occurred on line: 286 (Main)
java.lang.NullPointerException
    at com.astuetz.PagerSlidingTabStrip$PageListener.onPageScrolled(PagerSlidingTabStrip.java:346)
    at androidx.viewpager.widget.ViewPager.dispatchOnPageScrolled(ViewPager.java:1924)
    at androidx.viewpager.widget.ViewPager.onPageScrolled(ViewPager.java:1904)
    at androidx.viewpager.widget.ViewPager.pageScrolled(ViewPager.java:1842)
    at androidx.viewpager.widget.ViewPager.scrollToItem(ViewPager.java:694)
    at androidx.viewpager.widget.ViewPager.setCurrentItemInternal(ViewPager.java:670)
    at androidx.viewpager.widget.ViewPager.setCurrentItemInternal(ViewPager.java:631)
    at androidx.viewpager.widget.ViewPager.dataSetChanged(ViewPager.java:1086)
    at androidx.viewpager.widget.ViewPager$PagerObserver.onChanged(ViewPager.java:3097)
    at androidx.viewpager.widget.PagerAdapter.notifyDataSetChanged(PagerAdapter.java:291)
    at anywheresoftware.b4a.objects.TabStripViewPager.LoadLayout(TabStripViewPager.java:120)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
    at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:250)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
    at anywheresoftware.b4a.BA$2.run(BA.java:370)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5017)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
    at dalvik.system.NativeStart.main(Native Method)

Anybody have any ideas?

Thanks in advance.

Jim
 

AKJammer

Active Member
Licensed User
Hmmm, ok, well, I got it covered. Probably not the most elegant way, but it's simple and straight forward.

B4X:
Sub btnReset_LongClick
    Activity.RemoveAllViews
    Activity_Create(True)

End Sub
 
Upvote 0
Top