简体   繁体   English

Android NewsReader演示项目问题

[英]Android NewsReader Demo Project Problems

I downloaded the android demo newsreader project from here and imported it into eclipse using the Import > Existing Projects Into Workspace. 我从这里下载了android demo newsreader项目,并使用Import> Existing Projects Into Workspace将其导入eclipse。 I also added the android-support-v4.jar to the build path like it says here 我还添加了Android的支持,v4.jar到构建路径像它说在这里

The problem I am getting is something to do with accessing resources. 我遇到的问题与访问资源有关。 here are the errors I get. 这是我得到的错误。

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

I know it's not a lot to go on but I have been searching around and couldn't find anything as its quite a new demo. 我知道可以进行的操作不多,但是我一直在搜索,找不到任何东西,因为它是一个非常新的演示。

I think it could be that the R.java file is not being generated as I can't find it in my gen directory. 我认为可能是R.java文件未生成,因为我在gen目录中找不到该文件。 I have tried cleaning the project and restarting eclipse but they didnt work. 我试过清理项目并重新启动Eclipse,但是它们没有起作用。

Any help would be grand. 任何帮助将是巨大的。

Disco 迪斯科

Its been a while but this fixed the problem for me. 已经有一段时间了,但这为我解决了问题。
Did you import: 您输入了:

import android.app.ActionBar;

for some reason my project had: 由于某些原因,我的项目有:

import android.app.ActionBar.Tab;
import android.app.ActionBar.TabListener;

import android.app.ActionBar; and it worked. 而且有效。

您需要将构建目标更改为API Level 11或更高。

您需要单击Android Manifest.xml文件下的项目属性文件,然后将目标从8更改为目标13或更高。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM