我收到这个错误:
错误:错误:找不到与给定名称匹配的资源(在值为“@string/_____”的“文本”处)。
我多次更改字符串名称,但我仍然明白。我的代码有什么问题?以前可以用,但现在不行了。
xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:id="@+id/topLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="@+id/editTextMessage"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="20dp"
android:ems="10"
android:hint="@string/message"
android:singleLine="false" >
</EditText>
<EditText
android:id="@+id/editTextNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:layout_below="@+id/editTextMessage"
android:ems="10"
android:inputType="phone" >
</EditText>
<Button
android:id="@+id/buttonContact"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/editTextNumber"
android:layout_alignBottom="@+id/editTextNumber"
android:layout_alignParentRight="true"
android:text="@string/contact" />
<Button
android:id="@+id/buttonTimePickup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/buttonContact"
android:layout_marginTop="40dp"
android:text="@string/time" /> <--- the error appears on this line
<Button
android:id="@+id/buttonDatePickup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/buttonTimePickup"
android:layout_alignBottom="@+id/buttonTimePickup"
android:layout_alignParentRight="true"
android:layout_marginTop="40dp"
android:text="@string/date" /> <-- the error appears on this line
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/buttonDatePickup"
android:layout_marginTop="40dp"
android:text="@string/frequency" <--the error appears on this line
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="25sp" />
<RadioGroup
android:id="@+id/radioGroup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp">
<RadioButton
android:id="@+id/oneTime"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/onetime" /> < error appears on this line
<RadioButton
android:id="@+id/fifteenMinutes"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/fifteen" /> <-- error appears on this line
<RadioButton
android:id="@+id/halfHour"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/halfhour" /> <-- error appears on this line
<RadioButton
android:id="@+id/hour"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/anhour" /> <-- error appears on this line
<RadioButton
android:id="@+id/halfDay"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/halfday" /> <-- error appears on this line
<RadioButton
android:id="@+id/daily"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/daily" /> <-- error appears on this line
<RadioButton
android:id="@+id/weekly"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/week" /> <-- error appears on this line
<RadioButton
android:id="@+id/monthly"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/month" /> <-- error appears on this line
<RadioButton
android:id="@+id/Yearly"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/year" /> <-- error appears on this line
</RadioGroup>
<Button
android:id="@+id/buttonConfirm"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="@+id/radioGroup"
android:layout_marginTop="40dp"
android:text="@string/confirm" /> <-- error appears on this line
</RelativeLayout>
</LinearLayout>
</ScrollView>
我卡在这个了。
最佳答案
转到 res->values->strings.xml 并在里面添加下一行:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="time">time</string>
<string name="date ">date</string>
.............. etc for each string resource that you need
</resources>
关于android - 我需要有关 xml 错误的帮助(新手),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22491512/
当我使用Bundler时,是否需要在我的Gemfile中将其列为依赖项?毕竟,我的代码中有些地方需要它。例如,当我进行Bundler设置时:require"bundler/setup" 最佳答案 没有。您可以尝试,但首先您必须用鞋带将自己抬离地面。 关于ruby-我需要将Bundler本身添加到Gemfile中吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/4758609/
大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje
我有一个对象has_many应呈现为xml的子对象。这不是问题。我的问题是我创建了一个Hash包含此数据,就像解析器需要它一样。但是rails自动将整个文件包含在.........我需要摆脱type="array"和我该如何处理?我没有在文档中找到任何内容。 最佳答案 我遇到了同样的问题;这是我的XML:我在用这个:entries.to_xml将散列数据转换为XML,但这会将条目的数据包装到中所以我修改了:entries.to_xml(root:"Contacts")但这仍然将转换后的XML包装在“联系人”中,将我的XML代码修改为
刚入门rails,开始慢慢理解。有人可以解释或给我一些关于在application_controller中编码的好处或时间和原因的想法吗?有哪些用例。您如何为Rails应用程序使用应用程序Controller?我不想在那里放太多代码,因为据我了解,每个请求都会调用此Controller。这是真的? 最佳答案 ApplicationController实际上是您应用程序中的每个其他Controller都将从中继承的类(尽管这不是强制性的)。我同意不要用太多代码弄乱它并保持干净整洁的态度,尽管在某些情况下ApplicationContr
我注意到像bundler这样的项目在每个specfile中执行requirespec_helper我还注意到rspec使用选项--require,它允许您在引导rspec时要求一个文件。您还可以将其添加到.rspec文件中,因此只要您运行不带参数的rspec就会添加它。使用上述方法有什么缺点可以解释为什么像bundler这样的项目选择在每个规范文件中都需要spec_helper吗? 最佳答案 我不在Bundler上工作,所以我不能直接谈论他们的做法。并非所有项目都checkin.rspec文件。原因是这个文件,通常按照当前的惯例,只
我实际上是在尝试使用RVM在我的OSX10.7.5上更新ruby,并在输入以下命令后:rvminstallruby我得到了以下回复:Searchingforbinaryrubies,thismighttakesometime.Checkingrequirementsforosx.Installingrequirementsforosx.Updatingsystem.......Errorrunning'requirements_osx_brew_update_systemruby-2.0.0-p247',pleaseread/Users/username/.rvm/log/138121
我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test
我是rails的新手,想在form字段上应用验证。myviewsnew.html.erb.....模拟.rbclassSimulation{:in=>1..25,:message=>'Therowmustbebetween1and25'}end模拟Controller.rbclassSimulationsController我想检查模型类中row字段的整数范围,如果不在范围内则返回错误信息。我可以检查上面代码的范围,但无法返回错误消息提前致谢 最佳答案 关键是您使用的是模型表单,一种显示ActiveRecord模型实例属性的表单。c
我正在尝试编写一个将文件上传到AWS并公开该文件的Ruby脚本。我做了以下事情:s3=Aws::S3::Resource.new(credentials:Aws::Credentials.new(KEY,SECRET),region:'us-west-2')obj=s3.bucket('stg-db').object('key')obj.upload_file(filename)这似乎工作正常,除了该文件不是公开可用的,而且我无法获得它的公共(public)URL。但是当我登录到S3时,我可以正常查看我的文件。为了使其公开可用,我将最后一行更改为obj.upload_file(file
我克隆了一个rails仓库,我现在正尝试捆绑安装背景:OSXElCapitanruby2.2.3p173(2015-08-18修订版51636)[x86_64-darwin15]rails-v在您的Gemfile中列出的或native可用的任何gem源中找不到gem'pg(>=0)ruby'。运行bundleinstall以安装缺少的gem。bundleinstallFetchinggemmetadatafromhttps://rubygems.org/............Fetchingversionmetadatafromhttps://rubygems.org/...Fe