Android Question Panel.LoadLayout initialize Spinner on it.

MarcRB

Active Member
Licensed User
Hello,

In Activity_Create I load a basic layout file with some views/controls on it.
One of the views is a panel. And there are buttons next and previous.
The Activity is a kind of Wizard style. The buttons next and previous will set a variable named intStep.
The panel loads different layouts with more views on it, according the value of intStep.
So each time next or previous button was hit the panel wil be cleared and show an new layout.

My problem is some views/controls seemd to be not initialized.
But why... views that where created in a layout-editor should be initialized automatic.
And the loadlayout was done before.

Sub Global:
Private spiType As Spinner

Activity_Create:
Activity.LoadLayout("frmWizard")

LoadStepLayout(intStep as int):
PanContainers.RemoveAllViews
Select Case(intStep)
    Case 1:
            PanContainers.LoadLayout("panWizard_Registration")
    Case 1:
            PanContainers.LoadLayout("panWizard_Materials")
... ... ..........

LoadSpinnerType:
SpiType.Clear
SpiType.add("Type 1")
SpiType.add("Type 2")

The errorlog show spiType is not initialized. I also noticed pause.
Is there an activity_pause?

Error log:
java.lang.RuntimeException: Object should first be initialized (Spinner).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
    at anywheresoftware.b4a.objects.SpinnerWrapper.getSelectedIndex(SpinnerWrapper.java:62)
    at MyCompany.AppName.nl.actfx_wizard._activity_pause(actfx_objects.java:467)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
    at MyCompany.AppName.nl.actfx_wizard.onPause(actfx_objects.java:275)
    at android.app.Activity.performPause(Activity.java:7667)
    at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1469)
    at android.app.ActivityThread.performPauseActivityIfNeeded(ActivityThread.java:4334)
    at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4299)
    at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:4251)
    at android.app.servertransaction.PauseActivityItem.execute(PauseActivityItem.java:45)
    at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1993)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:216)
    at android.app.ActivityThread.main(ActivityThread.java:7266)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)

What is going wrong here?
 

MarcRB

Active Member
Licensed User
Found it....

In Activity_pause were some statemanager setting savings.
One of them was wrong because its will try to save data from a spinner on a layout that already was cleared.

Only question: Why is activity_pause triggerd. I Thought it was only triggerd when activity closed or Android make some space. But never during use of activity.
 
Upvote 0
Top