A AbbasMohammed Member Licensed User Longtime User Jul 27, 2013 #1 Kindly, i need to add image view to the scroll view (SV) from class prod (as in the code shown below, and then i can display message like (you clicked me) when i click on this image.But the below code didnt work and i get ( java.lang.NullPointerException) message!!! So please do you have any idea to help me Main Code: Copy Sub Globals Dim P As prod Dim SV As ScrollView:SV.Initialize (120%Y) SV.Panel.Color = Colors.Red End Sub Sub Activity_Create(FirstTime As Boolean) Activity.AddView(SV, 0,0,100%x,100%y) SV.Panel .AddView (P.a,0,0,30%x,30%y) End Sub Prod Class Code: Copy Sub Class_Globals Public a As ImageView End Sub 'Initializes the object. You can add parameters to this method if needed. Public Sub Initialize a.Initialize ("aaa") a.Bitmap=LoadBitmap(File.DirAssets ,"1.jpg") a.Gravity =Gravity.fill End Sub Public Sub aaa Msgbox("you clicked me","") End Sub Last edited: Jul 27, 2013
Kindly, i need to add image view to the scroll view (SV) from class prod (as in the code shown below, and then i can display message like (you clicked me) when i click on this image.But the below code didnt work and i get ( java.lang.NullPointerException) message!!! So please do you have any idea to help me Main Code: Copy Sub Globals Dim P As prod Dim SV As ScrollView:SV.Initialize (120%Y) SV.Panel.Color = Colors.Red End Sub Sub Activity_Create(FirstTime As Boolean) Activity.AddView(SV, 0,0,100%x,100%y) SV.Panel .AddView (P.a,0,0,30%x,30%y) End Sub Prod Class Code: Copy Sub Class_Globals Public a As ImageView End Sub 'Initializes the object. You can add parameters to this method if needed. Public Sub Initialize a.Initialize ("aaa") a.Bitmap=LoadBitmap(File.DirAssets ,"1.jpg") a.Gravity =Gravity.fill End Sub Public Sub aaa Msgbox("you clicked me","") End Sub
I IlCasti Active Member Licensed User Longtime User Jul 27, 2013 #2 Hi Hope this help you Main module Code: Copy Sub Globals Dim P As xxx Dim SV As ScrollView End Sub Sub Activity_Create(FirstTime As Boolean) SV.Initialize (120%Y) P.Initialize(SV) Activity.AddView(SV, 0,0,100%x,100%y) End Sub Class module Code: Copy Sub Class_Globals Private iw As ImageView Private p As Panel End Sub 'Initializes the object. You can add parameters to this method if needed. Public Sub Initialize(myIW As ScrollView) iw.Initialize ("aaa") iw.Bitmap=LoadBitmap(File.DirAssets ,"image.png") iw.Gravity =Gravity.fill myIW.Panel.AddView(iw,0,0,100%x,100%y) End Sub Public Sub iw_click Msgbox("you clicked me","") End Sub Bye IlCasti Upvote 0
Hi Hope this help you Main module Code: Copy Sub Globals Dim P As xxx Dim SV As ScrollView End Sub Sub Activity_Create(FirstTime As Boolean) SV.Initialize (120%Y) P.Initialize(SV) Activity.AddView(SV, 0,0,100%x,100%y) End Sub Class module Code: Copy Sub Class_Globals Private iw As ImageView Private p As Panel End Sub 'Initializes the object. You can add parameters to this method if needed. Public Sub Initialize(myIW As ScrollView) iw.Initialize ("aaa") iw.Bitmap=LoadBitmap(File.DirAssets ,"image.png") iw.Gravity =Gravity.fill myIW.Panel.AddView(iw,0,0,100%x,100%y) End Sub Public Sub iw_click Msgbox("you clicked me","") End Sub Bye IlCasti
I IlCasti Active Member Licensed User Longtime User Jul 27, 2013 #3 You can also follow this tutorial http://www.b4x.com/android/forum/threads/classes-tutorial.18626/#post-106825 Upvote 0
You can also follow this tutorial http://www.b4x.com/android/forum/threads/classes-tutorial.18626/#post-106825
A AbbasMohammed Member Licensed User Longtime User Jul 27, 2013 #4 Dear Sir, Many Thanks for your kind reply, and i shall check your solution and reply you ASAP. Yours Abbas Mohammed Upvote 0
Dear Sir, Many Thanks for your kind reply, and i shall check your solution and reply you ASAP. Yours Abbas Mohammed
A AbbasMohammed Member Licensed User Longtime User Jul 27, 2013 #5 Dear Sir, I am so happy to inform you that your solution worked like charm. Thank you Again Upvote 0