Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom SurfaceView causing NoSuchMethodException
    primarykey
    data
    text
    <p>I have a custom View extending SurfaceView. The XML layout is</p> <pre><code>&lt;com.myPackage.MyCustomView </code></pre> <p>android:id="@+id/mycview" android:layout_width="fill_parent" android:layout_height="fill_parent" /></p> <p>The class is : </p> <pre><code> public class MyCustomView extends SurfaceView{ public float[] xpositions; public float[] ypositions; public String[] units; public MyCustomView(Context context, float[] xpos, float[] ypos,String[] u) { super(context); xpositions=xpos; ypositions =ypos; units=u; } ... } </code></pre> <p>In the context Activity for this method I have the following line</p> <pre><code>MyCustomView mv = (MyCustomView)findViewById(R.id.mycview); </code></pre> <p>The LogCat output has the following </p> <pre><code>01-30 01:51:12.124: ERROR/AndroidRuntime(4934): Caused by: java.lang.NoSuchMethodException:MyCustomView(Context,AttributeSet) 01-30 01:51:12.124: ERROR/AndroidRuntime(4934): at java.lang.Class.getMatchingConstructor(Class.java:674) 01-30 01:51:12.124: ERROR/AndroidRuntime(4934): at java.lang.Class.getConstructor(Class.java:486) 01-30 01:51:12.124: ERROR/AndroidRuntime(4934): at android.view.LayoutInflater.createView(LayoutInflater.java:475) </code></pre> <p>For some reason my constructor is causing this exception. I would appreciate any help finding what is wrong with the code.</p> <p>UPDATE: I changed the constructor to add AttributeSet and in my activity wrote the following:</p> <pre><code> XmlPullParser parser = getResources().getXml(R.id.mycview); AttributeSet attributes = Xml.asAttributeSet(parser); MyCustomView cv =new MyCustomView(this,attributes,xx,yy,uu); cv= (MyCustomView)findViewById(R.id.mycview); </code></pre> <p>But I get the same logcat output.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload