Probably because you have a null pointer...  Logcat should be able to give
you the name of the file and the line number where the problem occurs, but I
would be willing to bet it is with this line:

Vg V = new Vg(this);    /* Vg is extending the ViewGroup */

I'm surprised that the application even compiles successfully.... That line
of code is not inside a method on your class so the "this" pointer is not
available yet, which is probably where the NullPointerException is coming
from.

What is the point of doing that anyway, when you later assign V to something
else with this line:

V = (Vg) findViewById(R.id.Layout);

Thanks,
Justin

----------------------------------------------------------------------
There are only 10 types of people in the world...
Those who know binary and those who don't.
----------------------------------------------------------------------


On Thu, Jan 28, 2010 at 6:58 AM, satish bhoyar <[email protected]>wrote:

> Hi all,
>
> I am trying to extend the ViewGroup in my application.
> then from my main activity i will create a variable of type following is
> the code snippet
>
> public class NewViewGrp extends Activity {
>
>     Vg V = new Vg(this);    /* Vg is extending the ViewGroup */
>     TextView Tv;
>
>     /** Called when the activity is first created. */
>     @Override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.main);
>         V = (Vg) findViewById(R.id.Layout);
>         Tv = (TextView) findViewById(R.id.TextView1);
>     }
>
> But when I am running the app it is failing. In logcat i m getting error as
> NullPointerException.
>
> What might be the reason?
>
> is it a correct way please tell the correct one.
>
> Thanks,
> satish
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Beginners" group.
>
> NEW! Try asking and tagging your question on Stack Overflow at
> http://stackoverflow.com/questions/tagged/android
>
> To unsubscribe from this group, send email to
> [email protected]<android-beginners%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-beginners?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to