【问题标题】:Android string resource Website not workingAndroid字符串资源网站不工作
【发布时间】:2017-09-28 11:15:27
【问题描述】:

每次我尝试从我的 android 资源字符串中读取网站时都会出错

<string name="API">http://google.com</string>

我的java代码是

String a =  getText(R.string.API).toString()+"search?q=";

【问题讨论】:

    标签: android xml string android-studio


    【解决方案1】:

    网址无效,'http://google.comsearch?q='。

    您必须在 xml 或 java 代码中添加斜杠 (/)。

    <string name="API">http://google.com/</string>
    

    String a =  getText(R.string.API).toString()+"/search?q=";
    

    【讨论】:

      【解决方案2】:

      尝试使用 getString(resId) 而不是 getText() 可能会有所帮助。

      String a =  getString(R.string.API)+"search?q=";
      

      【讨论】:

        猜你喜欢
        • 2017-04-16
        • 1970-01-01
        • 2013-04-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-10-23
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多