Reputation: 21891
I am extending spinner to add some functionality, I am trying to make the spinner a dropdown rather than dialog. So i am changing the spinner mode to drop down.
When I use this constructor, i get an exception
<mypackage.mypackage.MultiSelectionSpinner
android:id="@+id/my_spinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:spinnerMode="dropdown"
android:layout_weight="1"
android:padding="10dp" />
mySpinner = (MultiSelectionSpinner) findViewById(R.id.my_spinner);
public class MultiSelectionSpinner extends Spinner{
public MultiSelectionSpinner(Context context, AttributeSet attrs,int defStyle,int mode) {
super(context, attrs,defStyle,mode);
simple_adapter = new CustomerMultiSelectionSpinnerAdapter(context,
R.layout.customer_spinner_adapter_view, new ArrayList<String>() );
...
}
Caused by: android.view.InflateException: Binary XML file line #101: Error inflating class mypackage.mypackage.MultiSelectionSpinner at android.view.LayoutInflater.createView(LayoutInflater.java:603) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method) at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:631) at android.view.LayoutInflater.inflate(Native Method) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at android.view.LayoutInflater.inflate(LayoutInflater.java:353) at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:320) at android.app.Activity.setContentView(Activity.java:1895) at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217) at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:110) at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77) at mypackage.mypackage.MainActivity.onCreate(MainActivity.java:63) (which is basically the declaration mySpinner = (MultiSelectionSpinner) findViewById(R.id.my_spinner);) android.app.Activity.performCreate(Activity.java:5133) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2293) ... 12 more Caused by: java.lang.NoSuchMethodException: [class android.content.Context, interface android.util.AttributeSet] at java.lang.Class.getConstructorOrMethod(Class.java:423) at java.lang.Class.getConstructor(Class.java:397) at android.view.LayoutInflater.createView(LayoutInflater.java:568) ... 33 more
This however, works well, except the spinner is in dialog mode
public MultiSelectionSpinner(Context context, AttributeSet attrs) {
super(context, attrs);
simple_adapter = new CustomerMultiSelectionSpinnerAdapter(context,
R.layout.customer_spinner_adapter_view, new ArrayList<String>() );
super.setAdapter(simple_adapter);
}
Upvotes: 0
Views: 307
Reputation: 144
It seems like there is an error at line 101 in your spinner xml file. Check to see if everything is set up correctly.
Upvotes: 0