2013-10-02 48 views
-2

我爲android平臺編寫的代碼。 我宣佈在java文件 和我sound.xml我寫下面的代碼變量sound_on_state整型變量,我可以訪問xml文件中的變量嗎?如果是,那麼該怎麼辦?

enter code here 
<?xml version="1.0" encoding="utf-8"?> 
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"       
     android:oneshot="false"> 
<xsl:if sound_on_state > 0> /*this line give error as android prefix namespace*/ 
<item android:drawable="@drawable/sound_on_02" android:duration="50"/> 
<item android:drawable="@drawable/sound_on_01" android:duration="50"/> 
<xsl:else> 
<item android:drawable="@drawable/sound_off_02" android:duration="50"/> 
<item android:drawable="@drawable/sound_off_01" android:duration="50"/> 
</xsl:else> 
</xsl:if> 
</animation-list> 

回答

0

不,你不能。它應該從代碼中完成。將視圖塊添加到佈局,給它一個ID,然後在代碼中根據所需的任何條件更改其可見性。

相關問題