I have created my own custom spinner which I can access from "Custom and library views" as it implements View. But, the problem is that when drag my custom spinner from palette to use it in my main.xml, it throws "unhandled event loop exception". I don't know where is my mistake.

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:pref="http://schemas.android.com/apk/res/com.myspinner"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<com.myspinner.Myspinner
android:id="@+id/myspinner1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
pref:MyEntries="@array/testarray" />

MySpinnerattributes.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <declare-styleable name="MySpinner">
        <attr name="MyEntries" format="reference"/>
    </declare-styleable>
</resources>

spinnerlayout.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/textView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:text="@string/large_text" android:gravity="center"/>

Myspinner.java

    public class Myspinner extends Spinner{


    LayoutInflater inflater;
    CharSequence cs[]={"MySpinner"};
    String s[]={"MySpinner"};
    View row;
    TextView txt;


public Myspinner(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setAttributes(attrs);    
    this.setAdapter(new MyAdapter(this.getContext(), R.layout.spinnerlayout,s));
    }



publ
Edit
Report