0

I am following this link : android spinner fire event when same item selection is made

I extended Spinner class as mentioned in the link. Below is my code:

 public class SpinnerTrigger extends Spinner { public SpinnerTrigger(Context context) { super(context); // TODO Auto-generated constructor stub } @Override public void setSelection(int position, boolean animate) { ignoreOldSelectionByReflection(); super.setSelection(position, animate); } private void ignoreOldSelectionByReflection() { try { Class<?> c = this.getClass().getSuperclass().getSuperclass().getSuperclass(); Field reqField = c.getDeclaredField("mOldSelectedPosition"); reqField.setAccessible(true); reqField.setInt(this, -1); } catch (Exception e) { Log.d("Exception Private", "ex", e); // TODO: handle exception } } @Override public void setSelection(int position) { ignoreOldSelectionByReflection(); super.setSelection(position); } } 

I added the above class in my layout file with fully qualified name:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:orientation="vertical" tools:context=".MainActivity" > <com.mypack.cc.SpinnerTrigger android:id="@+id/spinner1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:entries="@array/options" android:prompt="@string/text_prompt" /> </LinearLayout> 

When I am trying run my application, I am getting error logs as mentioned below:

Caused by: android.view.InflateException: Binary XML file line #12:Error inflating class com.mypack.cc.SpinnerTrigger 

Please suggest me If I miss something here.

1
  • Please include the whole stack trace of the error Commented Feb 4, 2014 at 17:30

1 Answer 1

0

ASdd this to your layout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:tag="http://schemas.android.com/apk/res/com.mypack.cc" <!-- HERE --> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.