android - super simple custom view -


this should easy reason isn't working. wanted figure out how custom views, started doing 1 overrides button, adds no functionality, make sure works.

java (file foobutton.java):

package com.foo.bar;  import android.content.context; import android.widget.button;  public class foobutton extends button {       public foobutton(context context) {         super(context);     } } 

xml (within main.xml):

<view class="com.foo.bar.foobutton" android:text="blah" android:layout_width="wrap_content"  android:layout_height="wrap_content" android:id="@+id/buttonfoo"  android:textsize="24px" android:paddingleft="16px" android:width="100px" android:textstyle="bold" /> 

if replace "com.foo.bar.foobutton" "button", well, , button. if run above, crashes on startup , in logcat get:

e/androidruntime( 1411): caused by: android.view.inflateexception: binary xml file line #11: error inflating class com.foo.bar.foobutton

something simple i'm doing wrong?

you have override version of constructor takes attributeset:

public button (context context, attributeset attrs) 

this attributeset contain other values set in xml, such as:

android:text="blah" android:layout_width="wrap_content" 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -