Currently, I use this way, and it seems works. But there are shall be some better way, I think.
public MyView(Context context, AttributeSet attrs) { super(context, attrs); //Get the value from Activity this.mInt = ((MyActivity)context).getMyInt()); } On Wed, Apr 6, 2011 at 1:48 PM, android.xi...@gmail.com < android.xi...@gmail.com> wrote: > Hello Guys, > > I defined a customer view, e.g. MyView, which need to be constructed > with some own parameter, e.g. line number in the view, an integer. > The view will be employed by my activity, MyActivity. > It seems that the View's constructors are fixed and will be called by > the system, and I can do nothing on it. > > The question is: > How to pass the integer to the view during construction from > the activity, while I've known the integer in MyActivity? > > Thanks in advance. > Mike > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en