2014-01-07 32 views
1
<RadioButton android:id="@+id/radio2" 
    android:text="< 4 minutes" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" /> 

如果我通過「< 4分鐘」在文本xml給出錯誤。如何傳入<in xml?

可以任何方式實現XML這件事情?

請建議

+2

您需要轉義某些字符,就像其他任何XML文件一樣。嘗試'<'而不是'<'。 – thegrinner

回答

7

「<」 是HTML和XML的一個特殊字符。

要用它代替「<」與&#6 0 ;.

<RadioButton android:id="@+id/radio2" 
    android:text="&#60; 4 minutes" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" /> 

這裏是一個有益的聯繫,http://www.w3schools.com/tags/ref_entities.asp

3

試試這個:

<RadioButton android:id="@+id/radio2" 
    android:text="&lt; 4 minutes" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" />