Actually I first tried with findViewById() but it failed & gave me Null Pointer exception on Vg then I thought because the Vg is not initialized thats why it might be failing so i did that way.
I m not sure weather it is ok.. thanks, satish On Fri, Jan 29, 2010 at 3:08 AM, Justin Anderson <janderson....@gmail.com>wrote: > 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 <getsatonl...@gmail.com>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 >> android-beginners+unsubscr...@googlegroups.com<android-beginners%2bunsubscr...@googlegroups.com> >> 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 > android-beginners+unsubscr...@googlegroups.com<android-beginners%2bunsubscr...@googlegroups.com> > 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 android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en