문제

I want to include an item in my preferences.xml file that it contains a special character @.

           <EditTextPreference
            android:title="@string/pref_char_pares_title"
            android:summary="@string/pref_char_pares_summary"
            android:key="charseppares"
            android:defaultValue="@"/>      

But I have an error in line android:defaultValue="@"

(error: Error: No resource type specified (at 'defaultValue' with value '@').

I want to use the character @ like separator character in my strings. Thanks in Advance

도움이 되었습니까?

해결책

Can you try this

  <EditTextPreference
            android:title="@string/pref_char_pares_title"
            android:summary="@string/pref_char_pares_summary"
            android:key="charseppares"
            android:defaultValue="\@"/>

다른 팁

//you can also use like this to show special char

Unicode number: U+0040
HTML-code: &#64; 

Little late, but I had the same problem and maybe it will be helpful for somebody.

<EditTextPreference
android:title="@string/pref_char_pares_title"
android:summary="@string/pref_char_pares_summary"
android:key="charseppares"
android:defaultValue="\u0040"/>  
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top