Android中String一般都是定义在res/string.xml中,这样在程序中使用R.String.name就可以使用这个字符串了。但是想让这些定义的字符串能够灵活地根据参数来改变要怎么样才能实现呢?
实现起来其实很简单,在定义字符串的时候按照这样的格式来:
%1$sTEST%2$s
%x代表的是第几个参数,这里有两个参数,当然后面还可以加很多参数。$s代表的是参数的类型,使用的时候参数一定要与这里定义的相符,否则会出错。
使用的时候要这样使用: String s=this.getString(R.string.hello);
s=String.format(s, "a","b");
这样s的内容就会是aTESTb.
如果对string的定义是这样的:
%2$sTEST%1$s
s的内容将会是bTESTa
Android在getString()中添加参数
-
RunScriptError: Run "C:\Windows\system32\cmd.exe /d /s /c node-gyp rebuild
npm重启解决一切问题,npm疑难杂症,清空npm包缓存
-
intellij idea远程开发的几个想法
我之前是用idea上面自带的stfp来做的本地开发同步到linux服务器编译,但是我发现这个如果多个客户端同时开发,或者多个同事一起开发,服务器上的就不能更新到本地。是不能增量更新到本地,必须全部下载,比对下载也行,但是工程量打了就特别慢。
-
mount_osxfuse: the OSXFUSE file system is not available (255) fuse: failed to mount file system: Undefined
mount_osxfuse: the OSXFUSE file system is not available (255) fuse: failed to mount file system: Undefined
-
mount_osxfuse: the OSXFUSE file system is not available (255) fuse: failed to mount file system: Undefined
mount_osxfuse: the OSXFUSE file system is not available (255) fuse: failed to mount file system: Undefined
-
System Extension Blocked - warning
After upgrading your macOS computer to High Sierra 10.13.4 or higher (starting in April 2018), you may see a message about a System Extension Blocked. At Williams we have seen this warning appear for these programs:
-
wsl Ubuntu ssh连接被拒绝,连接不上
如果密码正常,一切正常的清空下连接不上,你可以试试重启ssh sudo /etc/init.d/ssh restart
-
win10上使用win-sshfs
首先在GitHub上下载DokanSetup-1.0.5.1000和WinSSHFS-1.6.1.13-devel 注意:Dokan不能使用最新的版本,得使用1.0.5版本。要不win-sshfs会报Dokan版本错误的问题。(win10版本)
-
Ubuntu安装Node.js和npm
Node.js是基于Chrome的JavaScript构建的跨平台JavaScript运行时环境,npm是Node.js的默认程序包管理器,也是世界上最大的软件注册表。本篇文章展示了三种在Ubuntu 20.04服务器上安装Node.js和npm的方法。
-
ubuntu 上 Node.js 安装和卸载
ubuntu 上 Node.js 安装和卸载
-
解决 Module build failed: Error: ENOENT: no such file or directory错误
解决 Module build failed: Error: ENOENT: no such file or directory错误