JayFang1993 / DropDownMenu

DropDownMenu for Android,Filter the list based on multiple condition.
https://fangjie.me
Apache License 2.0
809 stars 177 forks source link

Crash with some List<String[]> set as items #1

Closed hzw1199 closed 9 years ago

hzw1199 commented 9 years ago

final String[] arr1=new String[]{"世界圈","关注圈"}; final String[] arr2=new String[]{"全部分类","生活","职场"}; final String[] arr3=new String[]{"全部类型","文字","图片","声音"}; List<String[]> items=new ArrayList<>(); items.add(arr1); items.add(arr2); items.add(arr3);

I set above data as the menu data, and the app crashed.

05-02 01:35:21.290 13357-13357/com.jayfang.dropdownmenu.example E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.jayfang.dropdownmenu.example, PID: 13357 java.lang.ArrayIndexOutOfBoundsException: length=2; index=2 at com.jayfang.dropdownmenu.MenuListAdapter.getView(MenuListAdapter.java:81) at com.jayfang.dropdownmenu.DropDownMenu$4.onClick(DropDownMenu.java:278) at android.view.View.performClick(View.java:4785) at android.view.View$PerformClick.run(View.java:19869) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:155) at android.app.ActivityThread.main(ActivityThread.java) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)

hzw1199 commented 9 years ago

when I click the third menu it crashed

JayFang1993 commented 9 years ago

@hzw1199 you must call

mMenu.setMenuItems(items);

to bind data with the menu

Loyea commented 9 years ago

同个问题 当然已经setmenuitems

05-07 16:21:37.991: E/AndroidRuntime(11734): java.lang.ArrayIndexOutOfBoundsException: length=1; index=1 05-07 16:21:37.991: E/AndroidRuntime(11734): at com.jayfang.dropdownmenu.MenuListAdapter.getView(MenuListAdapter.java:81) 05-07 16:21:37.991: E/AndroidRuntime(11734): at com.jayfang.dropdownmenu.DropDownMenu$4.onClick(DropDownMenu.java:278)

JayFang1993 commented 9 years ago

@Loyea @hzw1199 thank you,i have repaired the bug