[英]How can I color Strings in the strings.xml file using HTML tags?
[英]How can I create automatic translations to my java file, by using strings.xml
一個月前,我開始學習Android Studio的基礎知識,目前正在制作一個應用程序。 該應用程序的原始語言為英語,但我也希望它使用荷蘭語。 我知道如何翻譯strings.xml文件,但是我很難翻譯Java中的單詞。 我嘗試使用此處或Google上任何地方列出的所有功能,但是我的應用崩潰了,或者甚至連英文單詞都出現了。 所以我想知道,如何翻譯應用程序中的單詞(一個,兩個和三個)(也許使用strings.xml?)x
公共類view_favourite擴展片段{
public view_favourite() {
// Required empty public constructor
}
SQLiteDatabase db;
int [] fav_array= new int[60];
int updated=0;
private static final int START_LEVEL = 1;
private int mLevel;
private Button mNextLevelButton;
private TextView mLevelTextView;
final String[] numberNames = {
"First","Second","Third"
} ;
抱歉,如果我需要上傳更多內容,我不知道這一切如何工作,我還有很多東西要學習。 (我知道收藏夾的拼寫是錯誤的:)
我希望我正確理解了這個問題。 這是從Java代碼中的資源獲取字符串的方法。 如果您有翻譯文件,則字符串將是其中之一。
public class Test extends Fragment {
void test(){
String first = getString(getContext(), R.string.first);
String second = getString(getContext(), R.string.second);
String third = getString(getContext(), R.string.third);
}
String getStringFromResources(Context context, int stringId){
return context.getString(stringId);
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.