我是一些新的android,我有一个应用程序代码,这是一个大项目。我理解所有编写的代码,但目前我遇到了问题。在我解释这个问题之前,我将列出这个应用程序正在使用的库。
以下是AndroidManifest文件中Android应用程序的应用程序设置
android:versionCode="7"
android:versionName="2.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="18" />
我在项目属性的Android类别的应用程序中包含了两个库。但是目前我收到了以下错误
home cant be resolved
在整个项目中。在我收到此错误的地方,会放置以下相同的代码:
if(item.getItemId()==android.R.id.home){
和android.R.id.home部分给出了错误。
修改: 清理完项目后,我在控制台中遇到了一些错误,如下所示:
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\ABS\res\values-v14\abs__styles.xml:22: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Holo.ActionBar.TabBar'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\ABS\res\values-v14\abs__styles.xml:24: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Holo.Light.ActionBar.TabBar'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\ABS\res\values-v14\abs__styles.xml:26: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Holo.Light.ActionBar.TabBar.Inverse'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\ABS\res\values\abs__styles.xml:101: error: Error: No resource found that matches the given name: attr 'android:textAllCaps'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\ABS\res\values-v14\abs__styles.xml:29: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Holo.ActionBar.TabText'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\ABS\res\values-v14\abs__styles.xml:31: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Holo.Light.ActionBar.TabText'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\ABS\res\values-v14\abs__styles.xml:33: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Holo.Light.ActionBar.TabText.Inverse'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\ABS\res\values-v14\abs__styles.xml:55: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Holo.Light.ActionMode.Inverse'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\ABS\res\values\abs__styles.xml:328: error: Error: No resource found that matches the given name: attr 'android:textAllCaps'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\ABS\res\values-v14\abs__styles.xml:93: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Holo.Widget.ActionBar.Menu'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\ABS\res\values-v14\abs__styles.xml:96: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Holo.Widget.ActionBar.Title'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\ABS\res\values-v14\abs__styles.xml:98: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Holo.Widget.ActionBar.Title.Inverse'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\ABS\res\values-v14\abs__styles.xml:100: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Holo.Widget.ActionBar.Subtitle'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\ABS\res\values-v14\abs__styles.xml:102: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Holo.Widget.ActionBar.Subtitle.Inverse'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\ABS\res\values-v14\abs__styles.xml:104: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Holo.Widget.ActionMode.Title'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\ABS\res\values-v14\abs__styles.xml:106: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Holo.Widget.ActionMode.Title.Inverse'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\ABS\res\values-v14\abs__styles.xml:108: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Holo.Widget.ActionMode.Subtitle'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\ABS\res\values-v14\abs__styles.xml:110: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Holo.Widget.ActionMode.Subtitle.Inverse'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\ABS\res\values-v14\abs__styles.xml:113: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Holo.Widget.PopupMenu'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\ABS\res\values-v14\abs__styles.xml:115: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Holo.Widget.PopupMenu.Large'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\ABS\res\values-v14\abs__styles.xml:117: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Holo.Widget.PopupMenu.Large'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\ABS\res\values-v14\abs__styles.xml:119: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Holo.Widget.PopupMenu.Small'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\ABS\res\values-v14\abs__styles.xml:121: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Holo.Widget.PopupMenu.Small'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\ABS\res\values-v14\abs__themes.xml:8: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light.DarkActionBar'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\ABS\res\values-v14\abs__themes.xml:14: error: Error: No resource found that matches the given name: attr 'android:actionBarWidgetTheme'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\Othaim\res\values-v11\styles.xml:3: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light.DarkActionBar'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\Othaim\res\values-v11\styles.xml:5: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Holo.ActionBar.TabBar'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\Othaim\res\values-v11\styles.xml:10: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light.DarkActionBar'.
[2013-09-10 16:04:30 - Othaim] D:\android\eclipse\Othaim\res\values\styles.xml:26: error: Error retrieving parent for item: No resource found that matches the given name 'android:style/Widget.Holo.ActionBar.TabView'.
ABS是ActionBarSherlock lib的项目。
我还检查了我的java文件,并且没有导入android.R.我也在堆栈交换中阅读了以下帖子:
R.id cannot be resolved on android ListActivity
但他们都没有解决我的问题。
请在这个问题上帮助我。
谢谢
答案 0 :(得分:7)
android.R.id.home
。要使用该常量编译代码,您需要将构建SDK设置为11或更高版本。请注意,因为它是static final
字面值,所以它在编译时内联,您可以在较低的API级别运行代码。
要回答您更新的问题:ActionBarSherlock需要构建SDK 14或更高版本,如its faq中所述:
使用此库要求它和您的项目都使用Android 4.0(API 14)或更新版本进行编译。
通常,您应该使用最新的构建SDK(截至目前为19)。只需注意当您尝试使用minSdkVersion中没有的功能时通知您的Android Lint错误。