SwipeCardView
SwipeCardView copied to clipboard
error
java.lang.NullPointerException at com.xiangying.view.custom.swipCard.SwipeFlingAdapterView.makeAndAddView(SwipeFlingAdapterView.java:166) at com.xiangying.view.custom.swipCard.SwipeFlingAdapterView.layoutChildren(SwipeFlingAdapterView.java:150) at com.xiangying.view.custom.swipCard.SwipeFlingAdapterView.onLayout(SwipeFlingAdapterView.java:127) at android.view.View.layout(View.java:14833) at android.view.ViewGroup.layout(ViewGroup.java:4631) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525) at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
我是打算把demo中的图片位置换成viewview播放视频 然后出现这个问题了
@smarthityou 按理只是替换控件,不会有问题,自己分析下,看还改了哪里
在SwipeFlingAdapterView中的makeAndAddView中FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) child.getLayoutParams();下面各个获取lp.topMargin + lp.bottomMargin会报空指针
@smarthityou 你不是用inflater.inflate(layoutId, parent, false)方法实例化view的吧,导致LayoutParams为空
我是在适配器里面用的,但也不至于这样吧。然后我在child.getLayoutParams();下面各个获取lp.topMargin + lp.bottomMargin用了try语句 如果出错就不获取lp.topMargin + lp.bottomMargin然后就不会有问题了 。 还有个问题就是 如果加上videoView的话锯齿就更严重了。