-
Notifications
You must be signed in to change notification settings - Fork 793
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
Don't call setOnClickListener for an AdapterView. You probably want setOnItemClickListener instead #63
Comments
version 1.10 |
can you show the whole implementation of dialogplus? |
//
|
When you use ViewHolder, you can't use OnItemClickListener, if you want to have click events of the individual views, use OnClickListener, or if you already handle it by yourself, just remove all click listeners from dialogplus. |
yes I have removed all click listeners before. But it throw the exception too. DialogPlus dialogPlus = DialogPlus.newDialog(getActivity())
.setContentHolder(new ViewHolder(viewGroup))
.setGravity(Gravity.BOTTOM)
.setCancelable(true)
.create();
dialogPlus.show(); |
I think that, when I give a custom viewgroup, the dialogplus also set the click event all children. But when I set a spinner in it. spinner can not set click event. android throw a exception. Can I forbidden the click event? |
Yes, it seems this is the exact reason and unfortunately there is no this option, but we should add this for these situations. You can only avoid this by creating spinner dynamically, dialogplus adds clicklistener only if the view has an id. |
oh! may be I can remove the id and try find it by the tag or parent find chid? |
That could also work but out of box, we already avoid to set clicklistener for adapterview. Need to check thorougly for this issue. |
ok. I try to remove the id and get it work. Thanks. |
cheers 👍 |
@wood23636 Can you show me your code,I can't solve it, Thanks. |
In my case I try to add onClickListener for spinner and I've got the same problem. I've crated workaround with touch listener: someSpinner.setOnTouchListener { _, event -> onTouchSomeSpinner(event)}
|
Hi, I want to add a whellview to dialogplus, it extend from spinner. but throw a exception.
07-25 22:13:30.493: E/AndroidRuntime(13740): java.lang.RuntimeException: Don't call setOnClickListener for an AdapterView. You probably want setOnItemClickListener instead
07-25 22:13:30.493: E/AndroidRuntime(13740): at com.jyxtec.wheel.TosAdapterView.setOnClickListener(TosAdapterView.java:803)
07-25 22:13:30.493: E/AndroidRuntime(13740): at com.orhanobut.dialogplus.DialogPlus.setClickListener(DialogPlus.java:315)
07-25 22:13:30.493: E/AndroidRuntime(13740): at com.orhanobut.dialogplus.DialogPlus.assignClickListenerRecursively(DialogPlus.java:300)
07-25 22:13:30.493: E/AndroidRuntime(13740): at com.orhanobut.dialogplus.DialogPlus.assignClickListenerRecursively(DialogPlus.java:297)
07-25 22:13:30.493: E/AndroidRuntime(13740): at com.orhanobut.dialogplus.DialogPlus.assignClickListenerRecursively(DialogPlus.java:297)
07-25 22:13:30.493: E/AndroidRuntime(13740): at com.orhanobut.dialogplus.DialogPlus.assignClickListenerRecursively(DialogPlus.java:297)
07-25 22:13:30.493: E/AndroidRuntime(13740): at com.orhanobut.dialogplus.DialogPlus.assignClickListenerRecursively(DialogPlus.java:297)
07-25 22:13:30.493: E/AndroidRuntime(13740): at com.orhanobut.dialogplus.DialogPlus.createView(DialogPlus.java:259)
07-25 22:13:30.493: E/AndroidRuntime(13740): at com.orhanobut.dialogplus.DialogPlus.initContentView(DialogPlus.java:227)
07-25 22:13:30.493: E/AndroidRuntime(13740): at com.orhanobut.dialogplus.DialogPlus.(DialogPlus.java:111)
07-25 22:13:30.493: E/AndroidRuntime(13740): at com.orhanobut.dialogplus.DialogPlusBuilder.create(DialogPlusBuilder.java:265)
The text was updated successfully, but these errors were encountered: