2016-06-22 21 views
0

我目前正在学习android开发大学模块,所以我很抱歉,如果这是一个非常基本的错误。我目前正在关注this tutorial,了解android java与普通java的不同之处等等。XML工具上下文错误

XML文件activity_main我收到以下错误:

Cannot resolve symbol ${relativePackage}.${activityClass} Validates resource references inside Android XML Files

我用谷歌和StackOverflow上搜索一下可能的解决方案,我发现由于恶劣的XML一些文章,说明它可以格式,这是我相信错误的地方。我也尝试运行该项目,它无法找到类文件R.我已经清理并重建了该项目,但错误仍在继续。

Here is my code if you would like to take a look。尽管目前它与教程网站非常相似。

我的XML:

<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="${relativePackage}.${activityClass}" > 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:layout_marginLeft="20dp" 
     android:layout_marginRight="20dp" 
     android:gravity="center" 
     android:orientation="vertical" > 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/welcome" 
      android:textSize="20dp" /> 

     <TextView 
      android:id="@+id/name" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:padding="10dp" 
      android:textColor="@color/lbl_name" 
      android:textSize="24dp" /> 

     <TextView 
      android:id="@+id/email" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textSize="13dp" /> 

     <Button 
      android:id="@+id/btnLogout" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="40dip" 
      android:background="@color/btn_logut_bg" 
      android:text="@string/btn_logout" 
      android:textAllCaps="false" 
      android:textColor="@color/white" 
      android:textSize="15dp" /> 
    </LinearLayout> 

</RelativeLayout> 

任何帮助是非常appreicated,谢谢

PS我使用过Android Studio

+0

relativePackage和activityClass是两个独立的错误 – NeedHelpSK

+0

后有错误的XML请在这里 –

+0

@JuanCruzSoler是有错误的http://pastebin.com/vcxvRd2R XML – NeedHelpSK

回答

1

我有同样的错误在我的布局文件,我发现这个解释。 “这是因为,在设计时应该没有添加任何组件,它是一个空活动,如果您想知道这个”$“符号混淆是什么,请放心,这只是一种配置方式文件让运行时间了解哪个Activity类与布局文件相关联。“ 所以,你可以在那里添加你的班级或删除这一行。