-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spinner Crashed!!!! #48
Comments
the same as you |
I solved the issue! @OverRide |
@anand2693 thank bro |
@anand2693 and...could u write the reason here to explain why the crash happend? |
Unfortunately, the above solution by anand2693 did not solve the crash for me. The crash occurs when I double click on the spinner before the dialog opened. So I had to create my own custom searchable spinner which extends searchable spinner: CustomSearchableSpinner.java:
Now in your activity inside OnItemSelectedListener set the isSpinnerDialogOpen variable to false.
You can see the working example of above code in my repository: Searchable Spinner |
@ashwindmk I really enjoyed your solution! By using it, I was able to make some adjustments in which the stability and the operation were further improved. Take a look... CustomSearchableSpinner.java public class CustomSearchableSpinner extends SearchableSpinner {
private boolean isSpinnerDialogOpen = false;
private Timer waitTimer;
public CustomSearchableSpinner(Context context) {
super(context);
}
public CustomSearchableSpinner(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CustomSearchableSpinner(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public void setIsSpinnerDialogOpen(Boolean value){
this.isSpinnerDialogOpen = value;
}
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
if (!isSpinnerDialogOpen) {
setIsSpinnerDialogOpen(true);
return super.onTouch(v, event);
}
}
if(waitTimer != null){
waitTimer.cancel();
}
temporizador();
return true;
}
private void temporizador(){
waitTimer = new Timer();
waitTimer.schedule(new TimerTask() {
@Override
public void run() {
setIsSpinnerDialogOpen(false);
}
}, 200);
}
} inside OnItemSelectedListener... myCustomSearchableSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
myCustomSearchableSpinner.isSpinnerDialogOpen = false;
...
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
myCustomSearchableSpinner.isSpinnerDialogOpen = false;
...
}
}); |
Thanks guys! This is great! I modified it a bit so that you do not have to set the isSpinnerDialogOpen=false every time (I hope it works well, I'm still a bit of a noob with Android): `
}` |
On multiple times click on spinner the app crash. if(!_searchableListDialog.isAdded()) { the issue will resolved |
@MindNotion |
@MindNotion |
@MindNotion First you need to extract the searchablespinnerlibrary-1.3.1-sources.jar file, edit the SearchableSpinner.java file at the line 91 and replace it with this code |
@MindNotion why you not raise PR for this fix? as this fixed the bug |
Here is my solution for our Xamarin.Android application in C#. using Android.Content; public class CustomSearchableSpinner : SearchableSpinner
} |
use this class and every thing will work fine for you public class CustomSearchableSpinner extends Spinner implements View.OnTouchListener,
} |
When I click the SearchableSinner throw Exception
java.lang.IllegalStateException: Fragment already added: SearchableListDialog{ad4f6610 #0 TAG}
at android.app.FragmentManagerImpl.addFragment(FragmentManager.java:1133)
at android.app.BackStackRecord.run(BackStackRecord.java:618)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1447)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:443)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
The text was updated successfully, but these errors were encountered: