Android Question spinner initial sub in diffrent line cause program crash

Maodge

Member
Licensed User
hello,
In my project , I create a layout name "HpStp".It has a panel view, and several spinners in panel.
when spinner initial sub before scv LoadLayout,like this, in Second Activity_Create

'对所有的spinner进行初始化
InitSpinner
'高度尺寸 当Hpstp尺寸变化时,需要做相应修改
scvHarpSetup.Panel.Height = 700dip
scvHarpSetup.Panel.Color = Colors.Black
'部件尺寸在designer中设定
scvHarpSetup.Panel.LoadLayout("HpStp")

InitSpinner sub do add items and set index of every spinner.
Prgram can complie with no warning log. It can show me Main Activity.but when I click button goto Second-Activity, Program crash.

And change spinner initial sub behine scvHarpSetup LoadLayout.
'高度尺寸 当Hpstp尺寸变化时,需要做相应修改
scvHarpSetup.Panel.Height = 700dip
scvHarpSetup.Panel.Color = Colors.Black
'部件尺寸在designer中设定
scvHarpSetup.Panel.LoadLayout("HpStp")
'对所有的spinner进行初始化
InitSpinner

Everything is OK.
My question is : all views are declare in globals sub, Why spinner add items and set index sub must behind LoadLayout?
 
Last edited:
Top