【问题标题】:Troubles with AndroidSlidingUpPanel with Eclipse - Error Inflating classEclipse 的 AndroidSlidingUpPanel 问题 - 膨胀类错误
【发布时间】:2016-04-19 23:23:52
【问题描述】:

我正在尝试使用 AndroidSlidingUpPanel library (在 Eclipse 中),但出现此错误:

04-19 20:09:48.413: E/AndroidRuntime(13760): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mendozatourapp/com.mendozatourapp.activitys.MapsActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class com.sothree.slidinguppanel.library.SlidingUpPanelLayout

这是我的布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".DemoActivity" >

    <com.sothree.slidinguppanel.SlidingUpPanelLayout
        xmlns:sothree="http://schemas.android.com/apk/lib/res-auto"
        android:id="@+id/sliding_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="bottom"
        sothree:panelHeight="68dp"
        sothree:shadowHeight="4dp"
        sothree:paralaxOffset="100dp"
        sothree:dragView="@+id/name">  
   </com.sothree.slidinguppanel.SlidingUpPanelLayout>
</RelativeLayout>

我下载了整个项目并将“main”作为库导入。然后我将此库添加到我的项目的 java 构建路径中。我感觉是java构建路径问题。有什么想法吗?

非常感谢您阅读我的内容并花时间去做。

【问题讨论】:

  • 你需要把它做成一个Eclipse的库项目。您是否将project.properties 文件和AndroidManifest.xml 文件添加到库中?
  • 是的,我做到了。谢谢。

标签: java android eclipse slidingpanelayout


【解决方案1】:

我刚刚让它在 Eclipse 中工作。

重要的部分是正确创建您的库项目,然后将其链接到您的主项目。

对于库项目,我创建了一个 project.properties 文件,还添加了 RecyclerView 库、support v4 库和 Nineoldandroids 的 jar 文件。

我还创建了一个 .classpath 文件,以使其自动将 java 文件夹放入构建路径中。

我将我正在工作的库项目上传到 github:https://github.com/dmnugent80/SlidingUpPanel-for-Eclipse/tree/master

然后,将库项目导入您的工作区:

将其设置为主项目的依赖:

所以,你最终会得到这样的结果:

然后,使用这个测试 xml(你的 xml 抛出一个关于需要至少两个孩子的错误):

<?xml version="1.0" encoding="utf-8"?>
<com.sothree.slidinguppanel.SlidingUpPanelLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:sothree="http://schemas.android.com/apk/res-auto"
    android:id="@+id/sliding_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="bottom"
    sothree:umanoPanelHeight="68dp"
    sothree:umanoShadowHeight="4dp"
    sothree:umanoParallaxOffset="100dp"
    sothree:umanoDragView="@+id/dragView"
    sothree:umanoOverlay="true"
    sothree:umanoScrollableView="@+id/list">

    <!-- MAIN CONTENT -->
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <TextView
            android:id="@+id/main"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="30dp"
            android:gravity="center"
            android:text="Main Content"
            android:clickable="true"
            android:focusable="false"
            android:focusableInTouchMode="true"
            android:textSize="16sp" />
    </FrameLayout>

    <!-- SLIDING LAYOUT -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#ffffff"
        android:orientation="vertical"
        android:clickable="true"
        android:focusable="false"
        android:id="@+id/dragView">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="68dp"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/name"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:textSize="14sp"
                android:gravity="center_vertical"
                android:paddingLeft="10dp"/>

            <Button
                android:id="@+id/follow"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:textSize="14sp"
                android:gravity="center_vertical|right"
                android:paddingRight="10dp"
                android:paddingLeft="10dp"/>

        </LinearLayout>

        <ListView
            android:id="@+id/list"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1">
        </ListView>
    </LinearLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>

有效!

【讨论】:

  • 我引用你的话,我很高兴这样做:“它有效!”。干得好丹尼尔。非常感谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-03-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-07-19
  • 2020-07-29
相关资源
最近更新 更多