junixapp / XPopup

🔥XPopup2.0版本重磅来袭,2倍以上性能提升,带来可观的动画性能优化和交互细节的提升!!!功能强大,交互优雅,动画丝滑的通用弹窗!可以替代Dialog,PopupWindow,PopupMenu,BottomSheet,DrawerLayout,Spinner等组件,自带十几种效果良好的动画, 支持完全的UI和动画自定义!(Powerful and Beautiful Popup for Android,can absolutely replace Dialog,PopupWindow,PopupMenu,BottomSheet,DrawerLayout,Spinner. With built-in animators , very easy to custom popup view.)
Apache License 2.0
7.71k stars 1.16k forks source link

AttachListPopupView增加自定义的横向列表时遇到疑惑 #262

Closed XpxDeveloper closed 5 years ago

XpxDeveloper commented 5 years ago

我测试的代码是这样的,最后的测试结果仍然是纵向列表,而不是横向列表: AttachListPopupView popupView = new AttachListPopupView(mContext) .setStringData(new String[]{"分享", "编辑", "不带icon"}, new int[]{R.mipmap.ic_launcher_round, R.mipmap.ic_launcher_round, R.mipmap.ic_launcher_round}) .setOffsetXAndY(0, 0) .bindItemLayout(R.layout.recycle_popup_item_text) .bindLayout(R.layout.recycle_popup_item_attach_impl_list) .setOnSelectListener(new OnSelectListener() { @Override public void onSelect(int position, String text) { ToastUtils.showLong(text); } }); popupView.popupInfo=new PopupInfo(); popupView.popupInfo.hasShadowBg=false; popupView.popupInfo.atView=v; popupView.popupInfo.popupType= PopupType.AttachView;

        popupView.show();

我在自己的项目里增加了2个布局:recycle_popup_item_text、recycle_popup_item_attach_impl_list; 以及HorizontalRecyclerView类。但是测试的时候,代码并没有执行到HorizontalRecyclerView里面,而是执行到了VerticalRecyclerView类里面,我暂时没搞懂是为什么

XpxDeveloper commented 5 years ago

知道原因了。getImplLayoutId()方法是在AttachPopupView构造方法中调用的,而new AttachListPopupView(mContext)时压根就还没调用方法bindLayout(R.layout.recycle_popup_item_attach_impl_list),所以这个源码上逻辑有缺陷,期待作者早点修复这个BUG

junixapp commented 5 years ago

不要自己new PopupInfo(),这个用法我没有写过,请按照文档的方法来使用。

XpxDeveloper commented 5 years ago

不要自己new PopupInfo(),这个用法我没有写过,请按照文档的方法来使用。

我就是因为文档中没有横向列表的写法,我才这么写呀。你的PopupInfo是在Builder里面实例化的,但是Builder里面提供的方法并不支持横向列表,我当然就只能自己写了,这还不对了?