AndroidSwipeLayout
AndroidSwipeLayout copied to clipboard
Reflective setting of gravity throws exception, dumping stacktraces in logs
I am using SwipeLayout with macroid in scala, so the SwipeLayout is created via code. It works great, but it fills the logs with exceptions, due to the following line:
https://github.com/daimajia/AndroidSwipeLayout/blob/d7a5759784c7399a1cbfe9b62c9fa6d0f257ab52/library/src/main/java/com/daimajia/swipe/SwipeLayout.java#L752
W/System.err(17183): java.lang.NoSuchFieldException: gravity
W/System.err(17183): at java.lang.Class.getField(Class.java:1138)
W/System.err(17183): at com.daimajia.swipe.SwipeLayout.addView(SwipeLayout.java:684)
W/System.err(17183): at android.view.ViewGroup.addView(ViewGroup.java:4064)
W/System.err(17183): at android.view.ViewGroup.addView(ViewGroup.java:4037)
It also works great for me but like you I am getting the same error.
Facing the same issue
I have managed to over go this exception by adding Layout params with gravity when adding view to swipeLayout:
swipeLayout.AddView(result, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent) { Gravity = GravityFlags.Center });
I have managed to over go this exception by adding Layout params with gravity when adding view to swipeLayout:
swipeLayout.AddView(result, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent) { Gravity = GravityFlags.Center });
I faced the same issue, much thank to you.