Android的替换字符串 [英] Android Replace Strings
本文介绍了Android的替换字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你如何替换字符串时,您检索的活动数据?我不能似乎找到谷歌。也许我的问题太简单了。请参阅下面的codeS。
意图= getIntent();
textToPass = in.getStringExtra(textToPass);
textToPass实际上是一个字符串,如。 ExampleText.txt
你如何删除.TXT,使它看起来像ExampleText
我可能是附近的某个地方,但我还是想不出弄清楚
字符串exampletext = textToPass.getText()的toString()代替(TXT)。;
解决方案
下面textToPass是字符串,这样你就可以直接申请替代方法就可以了。
textToPass.replace(TXT);
How do you replace strings when you retrieve a data from an activity ? I cant seems to find it google. Maybe my question is too simple. Please see the below codes.
Intent in = getIntent();
textToPass = in.getStringExtra("textToPass");
textToPass is actually a string eg. "ExampleText.txt"
How do you remove the .txt to make it look like "ExampleText"
I might be somewhere near, but I still couldnt figure out
String exampletext = textToPass.getText().toString().replace(".txt","");
解决方案
Here textToPass is string so you can directly apply replace method on it .
textToPass.replace(".txt","");
这篇关于Android的替换字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文