android替換字元串
❶ android textview style.setspan怎麼替換字元串
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="西堤牛排" android:id="@+id/top" android:textSize="40dip"(大小) android:textColor="#000000"(顏色) />
❷ android studio 重構包路徑
首先開發的工具得是android studio,eclipse自行跳過,很久沒用了。
比如我把原包路徑com.xxx.android 修改為com.test.android。win mac都可以,
只需2步就可輕松搞定:
1、在項目的文件系統裡面增加新包名的路徑,然後把舊包名的所有文件夾文件都拷貝到新包名目錄下,
2、接著去android studio,項目或者mole右鍵,點擊replace in path
然後把原包路徑和修改後的包路徑進行替換,項目不大的話估計幾分鍾內,如果比較大可能需要10幾分鍾,慢慢等它替換完畢。完畢後,運行項目,不報錯的話就說明OK 了,最後刪掉之前包名的文件目錄。當然同理,這個方法也可以替換全局字元串,再也不用一個一個的手動復制粘貼了。
❸ android怎麼改變string.xml的字元串
當時以為string resource都必須放在string.xml裡面 現在的我的習慣是根據activity來劃分string資源,這樣哪個界面顯示的字元串也就清楚了 比如登錄activity里的字元放在 strings_activity_login.xml 文件中 一些全局的資源放在 strings.xml 其他資源類似
❹ android 字元串能轉換成數組么
貌似沒有直接這樣轉換的方法,,,這個你可以這樣做先調用toString方法把數組轉換成一個["a","b","c"]這樣的一個字元串,然後通過字元串的替換方法replace(CharSequence target, CharSequence replacement) 把裡面的[]「」,都用空格替換掉,然後調用trim()去空格,然後得到一個「abc」這樣的字元串,然後調用字元串的toCharArray()或者getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) 就可以轉換成一個字元數組了 ...
❺ android 幾個經常用到的字元串的截取
幾個經常用到的字元串的截取
string str="123abc456";
int i=3;
1 取字元串的前i個字元
str=str.Substring(0,i); // or str=str.Remove(i,str.Length-i);
2 去掉字元串的前i個字元:
str=str.Remove(0,i); // or str=str.Substring(i);
3 從右邊開始取i個字元:
str=str.Substring(str.Length-i); // or str=str.Remove(0,str.Length-i);
4 從右邊開始去掉i個字元:
str=str.Substring(0,str.Length-i); // or str=str.Remove(str.Length-i,i);
5 判斷字元串中是否有"abc" 有則去掉之
using System.Text.RegularExpressions;
string str = "123abc456";
string a="abc";
Regex r = new Regex(a);
Match m = r.Match(str);
if (m.Success)
{
//綠色部分與紫色部分取一種即可。
str=str.Replace(a,"");
Response.Write(str);
string str1,str2;
str1=str.Substring(0,m.Index);
str2=str.Substring(m.Index+a.Length,str.Length-a.Length-m.Index);
Response.Write(str1+str2);
}
6 如果字元串中有"abc"則替換成"ABC"
str=str.Replace("abc","ABC");
************************************************
string str="adcdef"; int indexStart = str.IndexOf("d");
int endIndex =str.IndexOf("e");
string toStr = str.SubString(indexStart,endIndex-indexStart);
c#截取字元串最後一個字元的問題!
str1.Substring(str1.LastIndexOf(",")+1)
❻ java-Android怎麼把字元串轉換成Integer/Float/Double 中的一種
java總字元串轉換成其他基本數據類型的方式,可以使用基本數據類型的toString()方法,還有String類型轉換成其他的基本數據類型,示例如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
Integer I1=new Integer(i1);//生成Integer類
Float F1=new Float(f1); //生成Float類
Double D1=new Double(d1); //生成Double類
//分別調用包裝類的toString() 方法轉換為字元串
String si1=I1.toString();
String sf1=F1.toString();
Stringsd1=D1.toString();
Sysytem.out.println("si1"+si1);
Sysytem.out.println("sf1"+sf1);Sysytem.out.println("sd1"+sd1);
String MyNumber ="1234";
int MyInt = Integer.parseInt(MyNumber);
字元串轉換成byte, short, int, float, double, long 等數據類型,可以分別參考Byte, Short,Integer, Float, Double, Long 類的parseXXX 方法。
❼ android 從text讀取字元串用 textview顯示怎麼強制換行
用textview顯示一長串string,要多行顯示的時候,其實在要換行的後面直接加一個「」 「」
❽ 全部批量替換某文件夾下文件裡面的字元串(如android替換包名)
有時候需要把某個文件夾下的文件裡面的字元串內容全部替換成另外的字元串。
工具:sublime
操作步驟:
本次更改了264個文件,一個個保存肯定不現實,幸好sublime自帶保存全部的功能。
❾ Android有什麼方法可以替換字元嗎
實現思路:先獲取到特定位置的字元,之後直接替換即可
public class strRepalce {
public static void main(String[]args){
//要替換的一個字元串
String str="abcmdf";
//獲取指定字元位置 例如取 替換c字元
int i=str.indexOf("c");
//str.charAt(i) 取出指定字元(char類型 無法直接轉string) String.valueOf 轉換成string類型
String str2=String.valueOf(str.charAt(i));
//X為指定替換字元
str=str.replaceFirst(str2,"X");
❿ Android怎麼用正則表達式替換字元串某些字元
Strings1="www..com";
System.out.println(s1);
s1=s1.replaceAll("\.","/");
System.out.println(s1);