我有一个字符串数组,其中使用了%符号.正确使用的格式%是%.当我在该数组中有一个字符串有多个时%它给了我这个错误.
Multiple annotations found at this
line:
- error: Multiple substitutions specified in non-positional format;
did you mean to add the formatted="false" attribute?
- error: Found tag </item> where </string-array> is expected
Run Code Online (Sandbox Code Playgroud) 我有一个字符串,CurrentString并且是这样的形式
"Fruit: they taste good".
我想拆分CurrentString使用:作为分隔符.
这样,单词"Fruit"将被拆分为自己的字符串,"they taste good"并将成为另一个字符串.
然后我只想使用SetText()2个不同TextViews来显示该字符串.
什么是最好的方法来解决这个问题?
我有这个意图的问题.这个意图是为了发送文本类型的消息.一切都工作电子邮件,短信,推特和手机上的任何东西.但唯一有问题的是facebook,它会尝试发布链接而不是文本.
Intent s = new Intent(android.content.Intent.ACTION_SEND);
s.setType("text/plain");
s.putExtra(Intent.EXTRA_SUBJECT, "Quote");
s.putExtra(Intent.EXTRA_TEXT, qoute);
startActivity(Intent.createChooser(s, "Quote"));
Run Code Online (Sandbox Code Playgroud) 我正在使用此代码在Facebook上发布,但它不适用于官方Facebook应用程序,因为它试图发送为链接.有没有办法解决?
Intent s = new Intent(android.content.Intent.ACTION_SEND);
s.setType("text/plain");
s.putExtra(Intent.EXTRA_SUBJECT, "Quote");
s.putExtra(Intent.EXTRA_TEXT, qoute);
startActivity(Intent.createChooser(s, "Quote"));
Run Code Online (Sandbox Code Playgroud) 每次从strings.xml中定义的一组字符串中按下按钮时,我都会尝试显示一个随机字符串.这是字符串ID的示例
<string name="q0">
<string name="q1">
<string name="q2">
<string name="q3">
<string name="q4">
Run Code Online (Sandbox Code Playgroud)
用于获取随机字符串的java代码.
private static final Random rgenerator = null;
int RandomQ = R.string.q0 (rgenerator.nextInt(5) + 1);
String q = getString(RandomQ);
Run Code Online (Sandbox Code Playgroud)
如果我尝试使用这个java代码我在R.string.q0中的"q0"得到一个错误,The method q0(int) is undefined for the type R.string如果我尝试使用快速修复并创建一个方法,它的工作原理.但它不会让我保存或运行应用程序,因为它取代了我的创建方法并显示此消息
R.java was modified manually! Reverting to generated version!
Run Code Online (Sandbox Code Playgroud)
谢谢阅读.