我从here下载了android demo newsreader项目,并使用Import>将其导入eclipse;现有项目进入工作区。 我还将android-support-v4.jar添加到构建路径,就像它说here
一样我遇到的问题与访问资源有关。这是我得到的错误。
Description Resource Path Location Type
ReaderTutorial/src/com/example/android/newsreader line 143 Java Problem
android.app.ActionBar cannot be resolved to a variable NewsReaderActivity.java /NewsReaderTutorial/src/com/example/android/newsreader line 151 Java Problem
error: Error retrieving parent for item: No resource found that matches the given name 'android:style/Widget.Holo.Light.ActionBar.TabView'. style.xml /NewsReaderTutorial/res/values-v11 line 23 Android AAPT Problem
error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light.NoActionBar'. style.xml /NewsReaderTutorial/res/values-v11 line 33 Android AAPT Problem
error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light'. style.xml /NewsReaderTutorial/res/values-v11 line 28 Android AAPT Problem
error: Error: No resource found that matches the given name: attr 'android:actionBarTabStyle'. style.xml /NewsReaderTutorial/res/values-v11 line 30 Android AAPT Problem
error: Error: No resource found that matches the given name: attr 'android:actionBarTabTextStyle'. style.xml /NewsReaderTutorial/res/values-v11 line 29 Android AAPT Problem
FragmentTransaction cannot be resolved to a type CompatActionBarNavHandler.java /NewsReaderTutorial/src/com/example/android/newsreader line 54 Java Problem
FragmentTransaction cannot be resolved to a type CompatActionBarNavHandler.java /NewsReaderTutorial/src/com/example/android/newsreader line 76 Java Problem
FragmentTransaction cannot be resolved to a type CompatActionBarNavHandler.java /NewsReaderTutorial/src/com/example/android/newsreader line 84 Java Problem
OnNavigationListener cannot be resolved to a type CompatActionBarNavHandler.java /NewsReaderTutorial/src/com/example/android/newsreader line 35 Java Problem
R cannot be resolved to a variable ArticleActivity.java /NewsReaderTutorial/src/com/example/android/newsreader line 51 Java Problem
R cannot be resolved to a variable HeadlinesFragment.java /NewsReaderTutorial/src/com/example/android/newsreader line 75 Java Problem
R cannot be resolved to a variable NewsReaderActivity.java /NewsReaderTutorial/src/com/example/android/newsreader line 76 Java Problem
R cannot be resolved to a variable NewsReaderActivity.java /NewsReaderTutorial/src/com/example/android/newsreader line 80 Java Problem
R cannot be resolved to a variable NewsReaderActivity.java /NewsReaderTutorial/src/com/example/android/newsreader line 82 Java Problem
R cannot be resolved to a variable NewsReaderActivity.java /NewsReaderTutorial/src/com/example/android/newsreader line 86 Java Problem
R cannot be resolved to a variable NewsReaderActivity.java /NewsReaderTutorial/src/com/example/android/newsreader line 101 Java Problem
R cannot be resolved to a variable NewsReaderActivity.java /NewsReaderTutorial/src/com/example/android/newsreader line 152 Java Problem
R cannot be resolved to a variable NewsReaderActivity.java /NewsReaderTutorial/src/com/example/android/newsreader line 183 Java Problem
Tab cannot be resolved to a type CompatActionBarNavHandler.java /NewsReaderTutorial/src/com/example/android/newsreader line 54 Java Problem
Tab cannot be resolved to a type CompatActionBarNavHandler.java /NewsReaderTutorial/src/com/example/android/newsreader line 76 Java Problem
Tab cannot be resolved to a type CompatActionBarNavHandler.java /NewsReaderTutorial/src/com/example/android/newsreader line 84 Java Problem
TabListener cannot be resolved to a type CompatActionBarNavHandler.java /NewsReaderTutorial/src/com/example/android/newsreader line 35 Java Problem
The import android.app.ActionBar cannot be resolved CompatActionBarNavHandler.java /NewsReaderTutorial/src/com/example/android/newsreader line 19 Java Problem
The import android.app.ActionBar cannot be resolved CompatActionBarNavHandler.java /NewsReaderTutorial/src/com/example/android/newsreader line 20 Java Problem
The import android.app.ActionBar cannot be resolved CompatActionBarNavHandler.java /NewsReaderTutorial/src/com/example/android/newsreader line 21 Java Problem
The import android.app.FragmentTransaction cannot be resolved CompatActionBarNavHandler.java /NewsReaderTutorial/src/com/example/android/newsreader line 22 Java Problem
The method getActionBar() is undefined for the type NewsReaderActivity NewsReaderActivity.java /NewsReaderTutorial/src/com/example/android/newsreader line 137 Java Problem
The method onNavigationItemSelected(int, long) of type CompatActionBarNavHandler must override or implement a supertype method CompatActionBarNavHandler.java /NewsReaderTutorial/src/com/example/android/newsreader line 65 Java Problem
我知道这不是很多,但我一直在寻找并找不到任何新的演示。
我认为可能是因为我在gen目录中找不到它而没有生成R.java文件。我试过清理项目并重新启动eclipse,但它们没有用。
任何帮助都会很棒。
迪斯科
答案 0 :(得分:5)
已经有一段时间了,但这解决了我的问题 你导入了吗?
import android.app.ActionBar;
由于某种原因,我的项目有:
import android.app.ActionBar.Tab;
import android.app.ActionBar.TabListener;
import android.app.ActionBar;
它有效。
答案 1 :(得分:0)
您需要将构建目标更改为API级别11或更高级别。
答案 2 :(得分:0)
您需要单击Android Manifest.xml文件下的项目属性文件,并将目标从8更改为目标13或更高版本。