I tried MANY different places. For example I assigned it to a button and tried to get it onClick, I tried it when the class as created. OnCreate was the only spot that I found where it worked.
Been having lots of fun coding now. Although I found a bug in Canvas.drawRoundRect(), but I was able to work around it. Although eventually I need to figure out how to report the bug to Android, Back to work. Enjoy! On Jan 12, 6:31 pm, Kristopher Micinski <[email protected]> wrote: > Out of curiosity, where was it placed previously? > > kris > > On Thu, Jan 12, 2012 at 8:21 PM, JamesColeman > > > > > > > > <[email protected]> wrote: > > I got it. > > > I moved the following under onCreate and it started working > > > DrawingSurfaceView drawingsurface = > > (DrawingSurfaceView)findViewById(R.id.DrawingSurfaceView); > > > On Jan 12, 5:30 pm, JamesColeman <[email protected]> > > wrote: > >> I am wondering If I can get access to my mainActivity from my extend > >> SurfaceView somehow. Along the lines of > > >> public class DrawingSurfaceView extends SurfaceView implements > >> SurfaceHolder.Callback{ > > >> public DrawingSurfaceView(Context context, AttributeSet > >> attributeSet) { > >> super(context, attributeSet); > >> getHolder().addCallback(this); > > >> MyMainActivity myMainActivity = (MyMainActivity )."???" > >> myMainActivity.setDrawingSurfaceView(this); > >> } > > >> public MyMethod(){ > >> } > > >> } > > >> public class MyMainActivity extends Activity implements > >> OnClickListener{ > > >> public setDrawingSurfaceView(DrawingSurfaceView view){ > >> DrawingSurfaceView MyView = view; > >> } > > >> MyView.MyMethod(); > > >> Does anyone know a way to get "???". > > >> Thanks! > > >> On Jan 12, 1:14 pm, JamesColeman <[email protected]> > >> wrote: > > >> > Well this is embarrassing. Eclipse didn't choke on the following > >> > statement so I assumed it would work and put it up for the night. When > >> > I picked it up today the following code generates a null value. I even > >> > moved the code to a button so I could initiate it when I cold see the > >> > SurfaceView and it still generated a null value.. > > >> > DrawingSurfaceView drawingsurface = > >> > (DrawingSurfaceView)findViewById(R.id.DrawingSurfaceView); > > >> > It feels like I am so close. I will be doing some more experimentation > >> > today. However,if anyone has any thoughts on the subject, I would > >> > appreciate the input. > > >> > On Jan 11, 8:16 pm, JamesColeman <[email protected]> > >> > wrote: > > >> > > I must have missed something the first time I tried. This time it > >> > > worked the first time I tried it. I guess I must have have one of > >> > > those not so bright moments the first time I tried. Maybe it was late > >> > > at night. > > >> > > Thank you VERY VERY much. Since I already tried this and failed, it > >> > > would have taken me forever to figure this out on my own. You saved me > >> > > a LOT of time. > > >> > > Enjoy and good luck with your endeavors! > > >> > > On Jan 11, 8:05 pm, skink <[email protected]> wrote: > > >> > > > JamesColeman wrote: > >> > > > > Thank you for your reply!! > > >> > > > > I am not sure what doesn't make sense. I was told from a > >> > > > > developers > >> > > > > forum that I HAVE to use the xml file and extend surfaceview to > >> > > > > accomplish my goals. So that is what I did. It works, all I need > >> > > > > to > >> > > > > do now is call a method. > > >> > > > > The DrawingSurfaceView is created from the xml file, not my code, > >> > > > > so I > >> > > > > don't know how to format a call to mymethod. > > >> > > > > If it wasn't created from the xml file there are a couple of ways > >> > > > > for > >> > > > > me to call mymethod. For example if I create the class from where I > >> > > > > want to make the call I can do the following. > > >> > > > > DrawingSurfaceView MyView - new DrawingSurfaceView(); > >> > > > > MyView.myMethod(); > > >> > > > > However, I never create the MyView. It is created form the xlm > >> > > > > file. > > >> > > > > I do not think basic android questions involve xml layout files. > > >> > > > its 4am so I'm sure i missed something, but uf not, what abiut > >> > > > sumpke: > > >> > > > findViewById(R.id.DrawingSurfaceView) > > >> > > > called in your activity? > > >> > > > pskink > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Developers" group. > > To post to this group, send email to [email protected] > > To unsubscribe from this group, send email to > > [email protected] > > For more options, visit this group at > >http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

