0
我很困惑,爲什麼我需要有一個字符串,而不是硬編碼的TextView。 Eclipse告訴我我需要使用一個字符串,但我不想在我的strings.xml
中有多個字符串,所以我不會感到困惑。我應該怎麼做才能讓這些錯誤信息消失?硬編碼TextView和需要的字符串?
我很困惑,爲什麼我需要有一個字符串,而不是硬編碼的TextView。 Eclipse告訴我我需要使用一個字符串,但我不想在我的strings.xml
中有多個字符串,所以我不會感到困惑。我應該怎麼做才能讓這些錯誤信息消失?硬編碼TextView和需要的字符串?
這不會影響編譯時間,但擺脫了警告,將它添加到您的View
小號
tools:ignore="HardcodedText"
如
<TextView
android:id="@+id/large_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
tools:ignore="HardcodedText" />
或者,你可以打開皮棉窗口,提供更多選項,並批量處理這些警告。
轉到:
窗口 - >顯示視圖 - > Android的 - > lint警告。
然後您將得到所有警告的列表,您可以相應地處理它們。
這是很好的做法。這些只是警告,它根本不影響編譯。 –
嗯,我一直在爲Android開發很長時間,剛剛在我的設備上使用AIDE,然後我終於獲得了Eclipse,這就是發生了什麼 – user1956475
我知道如何使用Strings,並且始終使用它們,但是使用它們太煩人了。 – user1956475