This refers to R.layout.custom_display_view > View.inflate(context, R.layout.custom_display_view, null);
Whereas your layout file declares the View as: > custom_display_view1 I presume that this is a typo from trimming down the problem? Besides that, it should be R.id. not R.layout., so you could try: setContentView(R.layout.main); // or whatever your layout xml file is called CustomDisplayView customView = (CustomDisplayView ) findViewById(R.id.custom_display_view1); On Mar 5, 12:27 am, Michael Lam <[email protected]> wrote: > hi, > > i am trying to create my own custom view class. i want to know how to > add widgets such as > > Buttons, TextView and ImageView to this custom view. i am hoping that > this view can somehow > > use a layout xml file (programmatically styling it may be too hard). > Of course the main > > activity's layout xml file will include the custom view: > > <com.lam.customview.CustomDisplayView > android:id="@+id/custom_display_view1" > android:layout_width="fill_parent" > android:layout_height="fill_parent" /> > > i tried to do this: > > public CustomDisplayView(Context context, AttributeSet attrs) { > super(context, attrs); > > try > { > > SurfaceHolder holder = getHolder(); > holder.addCallback(this); > > View.inflate(context, R.layout.custom_display_view, null); > ... > > but i keep getting exceptions such as Error inflating class > > java.language.reflect.Contructor. > > my layout xml file just has a TextView and an ImageView, the content > of which will change > > based on certain conditions. > > can someone help me? thanks. -- 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

