开发者

How to pass a string param into an Android XML file?

开发者 https://www.devze.com 2023-03-15 04:10 出处:网络
Having a couple issu开发者_如何学编程es with this. I\'m using a sample Android XML file, and this is the line it uses<string name=\"search_results\">\\\'<xliff:g id=\"string\">%s</xliff

Having a couple issu开发者_如何学编程es with this. I'm using a sample Android XML file, and this is the line it uses <string name="search_results">\'<xliff:g id="string">%s</xliff:g>\'</string> which outputs: 'mystring'

I want it to output just mystring, without the quotes. If I take out the quotes in the xml file, I get s as the output. If I take out just one, I either get s' or 'mystring, depending on which mark is taken out. To be clear, I am literally getting the letter 's' as the output.

I couldn't find a simple tutorial on this, I figure one of you will know pretty quickly.

Thanks!


Did you happen to try:

<string name="search_results"><xliff:g id="string">%s</xliff:g></string>


What if you take the output with the quotes 'mystring' and then run that through a method that removes the quotes? Something like this:

public String removeQuotes(String value){
    if(value.startsWith("\'"){
        value = value.substring(1, value.length());
    }

    if(value.endsWith("\'"){
        value = value.substring(0, value.length()-1);
    }

    return value;

}

not sure if that would be feasible solution for you or not but it could be a temp fix if anything.

That code might not work 100% [I'm a tad rusty] just wanted to give an idea though. Hope it helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号