小编cer*_*ler的帖子

在TextView中更改一个单词的文本颜色

我正在寻找一种方法来改变在一个字的文本的颜色TextView从内Activity.

例如,有了这个:

String first = "This word is ";
String next = "red"
TextView t = (TextView) findViewById(R.id.textbox);
t.setText(first + next);
Run Code Online (Sandbox Code Playgroud)

如何将next文本颜色更改为红色?

string android colors textview

88
推荐指数
4
解决办法
8万
查看次数

Android:复制/复制SharedPreferences

有没有办法复制或复制SharedPreference?或者我需要从一个变量中获取每个变量然后将它们放在另一个变量中?

android sharedpreferences

10
推荐指数
3
解决办法
3944
查看次数

Android:将字符串的第一个字母转换为小写字母

我正在寻找一种方法将字符串的第一个字母转换为小写字母.我正在使用的代码从数组中提取随机字符串,在文本视图中显示字符串,然后使用它来显示图像.数组中的所有字符串的首字母大写,但存储在应用程序中的图像文件当然不能包含大写字母.

String source = "drawable/"
//monb is randomly selected from an array, not hardcoded as it is here
String monb = "Picture";

//I need code here that will take monb and convert it from "Picture" to "picture"

String uri = source + monb;
    int imageResource = getResources().getIdentifier(uri, null, getPackageName());
    ImageView imageView = (ImageView) findViewById(R.id.monpic);
    Drawable image = getResources().getDrawable(imageResource);
    imageView.setImageDrawable(image);
Run Code Online (Sandbox Code Playgroud)

谢谢!

string android capitalization

8
推荐指数
2
解决办法
2万
查看次数