1. 程式人生 > >android string.xml的字串中插入變數

android string.xml的字串中插入變數

http://www.cnblogs.com/fengzhblog/archive/2013/07/14/3188871.html

1.在string.xml檔案中定義字串及要插入的資料型別

<string name="ok">ok%1$d</string>

2.在class檔案中引用該字串:
String txtSelectOk = getResources().getString(R.string.ok);
txtSelectOk = String.format(txtSelectOk, "太棒了!");

相關推薦

android string.xml字串插入變數

http://www.cnblogs.com/fengzhblog/archive/2013/07/14/3188871.html 1.在string.xml檔案中定義字串及要插入的資料型別 <string name="ok">ok%1$d</string

Android string.xml字串的格式化和樣式

字串資源 字串資源為您的應用提供具有可選文字樣式和格式設定的文字字串。 共有三種類型的資源可為您的應用提供字串: String 提供單個字串的 XML 資源。 String Array 提供字串陣列的 XML 資源。 Qua

android string.xml 格式化字元

在string.xml中: <string name="reset_battery_low_dialog_message" formatted="false">"Battety is less than %1$d%, Can nott do that!"<

Android開發在string.xml檔案設定部分字型顏色大小

1.在string.xml檔案中: <stringname="exchange_txt_hint"><Data><![CDATA[請使用<font color="#ff0000"><b>%1$s</b&g

Android string.xml使用html標籤

一、使用HTML 方法1、使用 CDATA(推薦) <stringname="demo1"><Data><![CDATA[ <b>ABC</b> ]]></Data></stri

Mybatis的mapper.xml檔案插入資料返回自增主鍵

使用MyBatis往MySQL資料庫中插入一條記錄後,返回該條記錄的自增主鍵值。Mapper檔案應該怎麼寫呢? Mybatis的Mapper的標籤中有一個屬性,我們一起來看看: useGenerateKeys這個屬性,意思就是使用自增。我們需要將這個欄位設定為 true 。 同時,還需

當在寫androidxml檔案出現Unexpected text found in layout file: """的解決辦法

#當在寫android的xml檔案中出現Unexpected text found in layout file: “”"的解決辦法 當出現 Unexpected text found in layout file: “”" Incorrect line e

android string.xml裡的多空格字元

  編輯 string.xml 檔案的時候,字元之間的空格用多個 Space 鍵 只能顯示出一個Space鍵的效果 如: <string name="login_button_login">登 錄</string> 用了3個Space,但是結

[LeetCode] Reverse Words in a String 翻轉字串的單詞

Given an input string, reverse the string word by word. For example, Given s = "the sky is blue", return "blue is sky the". Update (2015-02-12):

[LeetCode] Unique Substrings in Wraparound String 封裝字串的獨特子字串

Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz", so s will look like this: "...zabcdefghijklmnopqrstuvwxyzabcd

[LeetCode] Reverse Vowels of a String 翻轉字串的母音字母

Write a function that takes a string as input and reverse only the vowels of a string. Example 1:Given s = "hello", return "holle". Example 2:Given s =

android AndroidManifest.xml檔案怎樣設定訪問網路的許可權

Android訪問網路的許可權是android.permission.INTERNET。 宣告許可權的方式:開啟 AndroidManifest.xml檔案在application節點之前增加 <uses-permission android:na

android string.xml 轉譯、特殊字元問題

在編輯 string.xml 檔案的時候,字元之間的空格用 Space 鍵是能顯示出效果的的,但是字元後面如果需要新增空格,直接 Space 鍵是不管用的,此時 空格應該用 &#160;來表示; 如: <string name="score">Sc

LeetCode | Reverse Words in a String字串的單詞序反轉)

Given an input string, reverse the string word by word. For example, Given s = "the sky is blue", return "blue is sky the". Clarific

Python在字串引用變數

在字串中加入變數有三種方法:1、+ 連字元name = 'zhangsan'print('my name is '+name)  #結果為 my name is zhangsan2、% 字元name = 'zhangsan'age = 25price = 4500.225pr

Android string.xml如何轉義&

經常做程式的時候,程式名會含有&的字元,此時,會出現變異不通過,如: <string name="app_name">Boy & Girl</string> 那麼此時該如何處理呢? 其實也很簡單,只需將&進行轉義即可,轉義

Android解析Xml字串例子

package a.test; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.StringReader;

【Linux】Shell - 字串插入字元

str="20171125" $ echo ${str:0:4}-${str:4:2}-${str:6} 2017-11-25 取子串 * $ var="get length of me" $ echo ${var:0:3} get $ echo ${var(-2)

React Native 之Text 在字串插入影象

/** * Sample React Native App * https://github.com/facebook/react-native * @flow */ import React, { Component } from 'react'; import

Android string.xml 顯示特殊符號

轉自:http://blog.csdn.net/wop_niaoren19870227/article/details/8671566 專案中要在string.xml 中顯示特殊符號,如@號冒號等,直接寫肯定不行啦。。只能考慮使用ASCII碼進行顯示:@號 &#06