我现有的项目使用 Fragments 和 FragmentPagerAdapters 运行顺利。但是,添加ActionBarSherlock
库时会出现错误。我发现 [another question] 有同样的问题,但没有答案。
在将库添加到我的项目之前,它看起来像这样,没有错误:
添加库后,我将其编辑AndroidManifest.xml
为 include android:theme="@android:style/Theme.Sherlock"
,这也会在我的 XML 文件中产生错误。当我将它更改为 时android:theme="@style/Theme.Sherlock"
,XML 文件中的错误消失了,但它仍然不起作用,错误如下所示:
编辑:
我已经完成了 CommonsWare 下面的回答中的建议,但我的代码仍然无法正常工作。所有错误都消失了,项目在我的设备上构建甚至启动。但是,当我输入 XML 文件的图形布局时,出现以下错误:
The following classes could not be found:
- android.support.v4.view.PagerTabStrip (Fix Build Path, Edit XML, Create Class)
这就是 XML 文件的样子。请注意,我的 XML 文件没有显示任何错误,但是当我进入Graphical Layout
选项卡时,会出现上述消息。我没有提到我正在使用 aViewPager
但我不认为它会有所作为。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/wavesMonitorMenuBar"
style="@android:style/ButtonBar"
android:layout_alignParentBottom="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/backButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/menu_back" />
<Button
android:id="@+id/readButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/menu_read" />
</LinearLayout>
<android.support.v4.view.ViewPager
android:id="@+id/statusPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_above="@id/wavesMonitorMenuBar" >
<android.support.v4.view.PagerTabStrip
android:id="@+id/pager_title_strip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="#9E9E9E"
android:textColor="#fff"
android:paddingTop="4dp"
android:paddingBottom="4dp" />
</android.support.v4.view.ViewPager>
</RelativeLayout>
从这里我去选择Fix Build Path
但仍然无法解决问题。我尝试选择两者library.jar
,android-support-v4.jar
但无济于事。当我尝试打开使用带有这些错误的 XML 文件的任何视图时,程序崩溃。
这是我选择时得到的窗口Fix Build Path
: