2 songge1308 songge1308 于 2016.02.23 13:43 提问

急!!!Android中swipelistview点进去就崩 2C

项目中用到了侧滑删除(SwipeListView),之前是直接用as关联的github上的库(就是as添加依赖的第一个,我不知道那是github上的还是哪里的),结果最近那个不能用了。只好找了个jar包,结果运行的时候一点进去接崩溃。试了好多种方法,还是不知道哪里出了问题,紧急求助,万分感谢。

02-23 07:02:52.995 1485-1485/com.jb.android.log E/AndroidRuntime: FATAL EXCEPTION: main
                                                                  android.view.InflateException: Binary XML file line #21: Error inflating class com.fortysevendeg.android.swipelistview.SwipeListView
                                                                      at android.view.LayoutInflater.createView(LayoutInflater.java:613)
                                                                      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
                                                                      at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
                                                                      at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
                                                                      at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
                                                                      at com.jb.android.log.fragment.LogListFragment.onCreateView(LogListFragment.java:80)
                                                                      at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:829)
                                                                      at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1035)
                                                                      at android.app.BackStackRecord.run(BackStackRecord.java:635)
                                                                      at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1397)
                                                                      at android.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:437)
                                                                      at android.support.v13.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:145)
                                                                      at android.support.v4.view.ViewPager.populate(ViewPager.java:1105)
                                                                      at android.support.v4.view.ViewPager.populate(ViewPager.java:951)
                                                                      at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1473)
                                                                      at android.view.View.measure(View.java:15172)
                                                                      at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814)
                                                                      at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1390)
                                                                      at android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
                                                                      at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
                                                                      at android.view.View.measure(View.java:15172)
                                                                      at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814)
                                                                      at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
                                                                      at android.view.View.measure(View.java:15172)
                                                                      at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814)
                                                                      at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1390)
                                                                      at android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
                                                                      at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
                                                                      at android.view.View.measure(View.java:15172)
                                                                      at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814)
                                                                      at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
                                                                      at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2148)
                                                                      at android.view.View.measure(View.java:15172)
                                                                      at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1848)
                                                                      at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1100)
                                                                      at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1273)
                                                                      at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998)
                                                                      at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4212)
                                                                      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
                                                                      at android.view.Choreographer.doCallbacks(Choreographer.java:555)
                                                                      at android.view.Choreographer.doFrame(Choreographer.java:525)
                                                                      at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
                                                                      at android.os.Handler.handleCallback(Handler.java:615)
                                                                      at android.os.Handler.dispatchMessage(Handler.java:92)
                                                                      at android.os.Looper.loop(Looper.java:137)
                                                                      at android.app.ActivityThread.main(ActivityThread.java:4745)
                                                                      at java.lang.reflect.Method.invokeNative(Native Method)
                                                                      at java.lang.reflect.Method.invoke(Method.java:511)
                                                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
                                                                      at dalvik.system.NativeStart.main(Native Method)
                                                                   Caused by: java.lang.reflect.InvocationTargetException
                                                                      at java.lang.reflect.Constructor.constructNative(Native Method)
                                                                      at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
                                                                      at android.view.LayoutInflater.createView(LayoutInflater.java:587)
                                                                      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687) 
                                                                      at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
                                                                      at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
                                                                      at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
                                                                      at com.jb.android.log.fragment.LogListFragment.onCreateView(LogListFragment.java:80) 
                                                                      at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:829) 
                                                                      at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1035) 
                                                                      at android.app.BackStackRecord.run(BackStackRecord.java:635) 
                                                                      at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1397) 
                                                                      at android.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:437) 
                                                                      at android.support.v13.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:145) 
                                                                      at android.support.v4.view.ViewPager.populate(ViewPager.java:1105) 
                                                                      at android.support.v4.view.ViewPager.populate(ViewPager.java:951) 
                                                                      at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1473) 
                                                                      at android.view.View.measure(View.java:15172) 
                                                                      at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814) 
                                                                      at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1390) 
                                                                      at android.widget.LinearLayout.measureVertical(LinearLayout.java:681) 
                                                                      at android.widget.LinearLayout.onMeasure(LinearLayout.java:574) 
                                                                      at android.view.View.measure(View.java:15172) 
                                                                      at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814) 
                                                                      at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) 
                                                                      at android.view.View.measure(View.java:15172) 
                                                                      at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814) 
                                                                      at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1390) 
                                                                      at android.widget.LinearLayout.measureVertical(LinearLayout.java:681) 
                                                                      at android.widget.LinearLayout.onMeasure(LinearLayout.java:574) 
                                                                      at android.view.View.measure(View.java:15172) 
                                                                      at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814) 
                                                                      at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) 
                                                                      at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2148) 
                                                                      at android.view.View.measure(View.java:15172) 
                                                                      at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1848) 
                                                                      at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1100) 
                                                                      at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1273) 
                                                                      at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998) 
                                                                      at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4212) 
                                                                      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725) 
                                                                      at android.view.Choreographer.doCallbacks(Choreographer.java:555) 
                                                                      at android.view.Choreographer.doFrame(Choreographer.java:525) 
                                                                      at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711) 
                                                                      at android.os.Handler.handleCallback(Handler.java:615) 
                                                                      at android.os.Handler.dispatchMessage(Handler.java:92) 
                                                                      at android.os.Looper.loop(Looper.java:137) 
                                                                      at android.app.ActivityThread.main(ActivityThread.java:4745) 
                                                                      at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                      at java.lang.reflect.Method.invoke(Method.java:511) 
                                                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
                                                                      at dalvik.system.NativeStart.main(Native Method) 
                                                                   Caused by: java.lang.RuntimeException: You forgot the attributes swipeFrontView or swipeBackView. You can add this attributes or use 'swipelist_frontview' and 'swipelist_backview' identif

根据报错,最后一行说我是没写frontview或者backview,可是这些都写了啊。
debug的时候是加载布局的时候就报错。

   View view = inflater.inflate(R.layout.fragment_log_list, container, false);

这是我的swipelistview布局文件

<com.fortysevendeg.android.swipelistview.SwipeListView
        xmlns:swipe="http://schemas.android.com/apk/res-auto"
        android:id="@+id/log_listview"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        swipe:swipeBackView="@+id/log_listview_item_back2"
        swipe:swipeCloseAllItemsWhenMoveList="true"
        swipe:swipeFrontView="@+id/log_listview_item_front2"
        swipe:swipeOffsetLeft="150dp"
        swipe:swipeMode="left"
        swipe:swipeActionLeft="reveal"
        swipe:swipeActionRight="reveal"
        swipe:swipeAnimationTime="100"
        swipe:swipeOffsetRight="80dp"
        swipe:swipeOpenOnLongPress="false"/> 

5个回答

songge1308
songge1308   2016.02.23 13:43

谁遇到过类似的问题,求解决思路

lanlande_vip
lanlande_vip   2016.02.23 14:11

swipe:swipeBackView="@+id/log_listview_item_back2"
swipe:swipeFrontView="@+id/log_listview_item_front2"

这两个设置为一个单独的layout文件,而非@+id/xxx

试试看把

u011249920
u011249920   2016.02.23 14:33

看错误提示就是没有找到资源文件,试试在res/下建一目录drawable/,将drawable-mdpi/ ,drawable-hdpi/ 等 下所有的资源文件都拷贝到drawable/下即可

include__cc
include__cc   2016.02.23 14:58

android.view.InflateException这个错误一般按照下面的思路排查。
1、xml本身有错。检查后发现xml没错的话,就进行第二步
2、运行程序debug,关注使用到LayoutInflate的地方,仔细查看,在你Inflate的view里面有没有你要找的控件,一般id重复,使用布局重复,会出现类似问题
,还有注意使用adapter的地方,这里面的 错误较隐蔽,一般抛到logcat里面就一句话的错误,还是黄色的警告,在这里面debug。
顺便说一下,你使用的那个Github的源码本身没错,我们项目就用到来,只不过修改了一下。单纯看你贴出来的 内容定位不了错误

songge1308
songge1308 谢谢回答,我debug的时候在创建布局的时候就出现错误了,把这个控件(swipelistview)放到不同的界面中,点击进去还是会报这样的错误
接近 2 年之前 回复
qq_17805097
qq_17805097   2016.02.23 15:33

android.view.InflateException: Binary XML file line #21: Error inflating class com.fortysevendeg.android.swipelistview.SwipeListView

报错都说了 XML 21行有问题,请注意详细排查。

songge1308
songge1308 就是这个 <com.fortysevendeg.android.swipelistview.SwipeListView
接近 2 年之前 回复
songge1308
songge1308 感谢回答,21行就是布局文件
接近 2 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!