Concatenate multiple strings in XML?

前端 未结 10 997
执笔经年
执笔经年 2020-12-01 05:09

I go through this How to concatenate multiple strings in android XML? and in the end there are comments that

For clarity, Its works:

&

10条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-01 05:22

    How about this technique

    Use an array

    https://myapp.com/
    
    
        Update can be downloaded manually by visiting this link:\n
        @string/app_link
    
    

    And then make a method in java class as below

    public String getStringArray(int resStringArray)
    {
        String str = "";
    
        String[] strArray = mContext.getResources().getStringArray(resStringArray);
        for (String s: strArray)
        {
            str += s;
        }
    
        return str;
    }
    

    Now call it from any java class as

    mDialog.setMessage(getStringArray(R.array.update_dialog_msg);
    // OR
    textView.setText(getStringArray(R.array.update_dialog_msg);
    

提交回复
热议问题