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 [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 
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 [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

Reply via email to