Re: [android-developers] ListView ClassCastException
Oh i got the problem.It was incorrectly declared in the layout.Will try the chages now.. Thanks a lot Michael. On Mon, Aug 30, 2010 at 10:47 PM, Michael MacDonald < googlec...@antlersoft.com> wrote: > On 08/30/10 06:59, Alok Kulkarni wrote: > > Hi all,in my application I have a class as: > >1. public class TouchInterceptor extends ListView > > and my main activity class as: > > >1. public class GUIEngine extends Activity > > > in this class i initialize my ListView variable as: > > >1. lView = (ListView) findViewById(R.id.mainList); > > > now i want to set a listener on this lview object which is in my > TouchInterceptor class, i do that as: > > >1. ((TouchInterceptor) lView).setDropListener(mDropListener); > > > but i get a ClassCastException at this line. > what am i doing wrong? > > plzz can anyone help.. thank u > > > -- > 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 > > How are you creating mainList? If you are doing it with a layout, are you > declaring it as a TouchInterceptor in the layout? > > You can't cast any old object to a derived class of its declared type; you > can only downcast if the object was created with the derived class. > > -- > 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 -- 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
Re: [android-developers] ListView ClassCastException
On 08/30/10 06:59, Alok Kulkarni wrote: > Hi all,in my application I have a class as: > > 1. > public class TouchInterceptor extends ListView > > and my main activity class as: > > 1. > public class GUIEngine extends Activity > > > in this class i initialize my ListView variable as: > > 1. > lView = (ListView) findViewById(R.id.mainList); > > > now i want to set a listener on this lview object which is in my > TouchInterceptor class, i do that as: > > 1. > ((TouchInterceptor) lView).setDropListener(mDropListener); > > > but i get a ClassCastException at this line. > what am i doing wrong? > > plzz can anyone help.. thank u > > > -- > 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 How are you creating mainList? If you are doing it with a layout, are you declaring it as a TouchInterceptor in the layout? You can't cast any old object to a derived class of its declared type; you can only downcast if the object was created with the derived class. -- 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
[android-developers] ListView ClassCastException
Hi all,in my application I have a class as: 1. public class TouchInterceptor extends ListView and my main activity class as: 1. public class GUIEngine extends Activity in this class i initialize my ListView variable as: 1. lView = (ListView) findViewById(R.id.mainList); now i want to set a listener on this lview object which is in my TouchInterceptor class, i do that as: 1. ((TouchInterceptor) lView).setDropListener(mDropListener); but i get a ClassCastException at this line. what am i doing wrong? plzz can anyone help.. thank u -- 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