2015-02-23 45 views
0

我寫這個xml文件保存沒有錯誤,並顯示我期望它在eclipse中的預覽。但是,如果有足夠的時間(大約5-10分鐘),在繼續處理項目的其他部分(如實際的Java文件)之後,該文件會引發錯誤。xml保存沒有錯誤,但幾分鐘後有一個錯誤

這是抱怨,因爲我錨定到一個視圖,在xml文件中進一步聲明。但我無法解決這個問題,因爲所有3個主要部分都相互依賴。如果我改變它,它看起來不太好。

我該如何解決這個問題?

<!-- The chat bubble --> 
<RelativeLayout 
    android:id="@+id/chat_bubble_wrapper" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="5dp"> 

    <!-- The user's name above the chat bubble --> 
    <TextView 
     android:id="@+id/chat_bubble_username" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@id/chat_bubble_comment" ERROR HERE!!!! 
     android:layout_marginLeft="9dip" 
     android:textSize="12sp" 
     android:text="Username" 
     android:textColor="#88000000"> 
     </TextView> 

    <TextView 
     android:id="@+id/chat_bubble_comment" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/chat_bubble_username"    
     android:layout_toRightOf="@id/chat_bubble_profile_picture" 
     android:layout_margin="5dip" 
     android:background="@drawable/bubble_yellow" 
     android:paddingLeft="4dp" 
     android:text="Hello bubbles!" 
     android:textColor="@android:color/primary_text_light" /> 

    <!-- The user's profile picture next to the chat bubble --> 
    <ImageView 
     android:id="@+id/chat_bubble_profile_picture" 
     android:layout_marginLeft="10dip" 
     android:layout_width="32dp" 
     android:layout_height="32dp" 
     android:background="#000000" 
     android:layout_alignTop="@id/chat_bubble_comment" 
     /> 



</RelativeLayout> 

回答

1

變化

android:layout_alignLeft="@id/chat_bubble_comment" 

android:layout_alignLeft="[email protected]+id/chat_bubble_comment" 
+0

我想'+ @ ID/chat_bubble_comment'應該'@ + ID/chat_bubble_comment' – 2015-02-23 07:33:37

+0

是的..錯字錯誤 – Fahim 2015-02-23 07:35:05

+0

@Fahim哇我不知道你可以做到這一點。我是否應該按照它們的方式(加號)保留所有ID屬性?我不完全確定加號現在是如何工作的(你只是翻轉了我的世界)。 我還需要爲中間元素中的'layout_toRightOf'屬性執行此操作。如果它在隨後的15分鐘內沒有隨機決定拋出錯誤,我會接受這個答案。 – Kacy 2015-02-23 07:39:22