2014-09-06 21 views
0
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/BtnRecipe" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
tools:context="net.androidbootcamp.healthyrecipes.MainActivity" > 

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="19dp" 
    android:text="Guacamole Recipe" 
    android:textSize="34sp" /> 

<Button 
    android:id="@+id/button1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/imageView1" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="92dp" 
    android:text="View Recipe" 
    android:textSize="30sp" /> 

<ImageView 
    android:id="@+id/imageView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignRight="@+id/button1" 
    android:layout_below="@+id/textView1" 
    android:layout_marginTop="48dp" 
    android:src="@drawable/Guacamole" /> 

<ImageView 
    android:id="@+id/imageView2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/textView1" 
    android:layout_centerHorizontal="true" 
    android:src="@drawable/guacamole" /> 

R可以解決不了的/沒有種源發現匹配給定的名稱

這是我的主要活動。我在Windows 8.1上運行Juno。

我知道「R無法解決」已經被問過很多次了,我找不到可以幫助我的答案。我在第14,21和31行有「R」錯誤。

我也有錯誤:找不到與給定名稱匹配的資源('src'中值爲'@ drawable/Guacamole')。 activity_main.xml line 32

我有一個項目,因爲明天,任何幫助非常感謝,如果有任何提示在8.1中運行Eclispe也將不勝感激。

+0

我已經嘗試清理我的項目,並且這些錯誤未得到解決。 – 2014-09-06 21:12:01

+2

這應該不是用Windows 8.1標記的。 – 2014-09-06 21:16:57

+0

我的教授曾表示預計Windows 8.1的併發症,我不知道這個錯誤是否涉及8.1。抱歉。 – 2014-09-06 21:20:22

回答

0

再次

<ImageView 
android:id="@+id/imageView1" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_alignRight="@+id/button1" 
android:layout_below="@+id/textView1" 
android:layout_marginTop="48dp" 
android:src="@drawable/Guacamole" /> 

<ImageView 
android:id="@+id/imageView2" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_below="@+id/textView1" 
android:layout_centerHorizontal="true" 
android:src="@drawable/guacamole" /> 

看到你在你的代碼在第二圖像視圖中@drawale/guacamole是小,第一個是大@drawable/Guacamole完蛋了。

+0

哪裏?我對代碼知之甚少。 – 2014-09-06 21:13:21

+0

再次看到我已編輯的代碼 – 2014-09-06 21:15:46

+0

感謝您的支持,我應該在什麼行添加導入R代碼? – 2014-09-06 21:17:51

0

錯誤成爲因爲您使用不正確的名稱爲您的繪圖。
繪製正好可以利用lowwer情況leeter雖然res/drawable文件夾命名圖片從來不使用大寫字母(A-Z和數量,而不是用數字開頭)

0

您可以使用數字,但不要用數字開頭。在你的情況,你已經給Guacamole具有資本「G'.Change這麼別的東西,並在你的佈局android:src="@drawable/somegoodname"

而且可以肯定的是,在你的活動,你有沒有進口R.android.使用相同的名稱,而不是import R.YOUR PACKAGE NAME.

如果這不能解決您的問題,請參考r-cannot-be-resolved-android-error找出產生此錯誤的各種原因。

相關問題