如何在Java中连接后设置XML字符串?(How to set XML string after concat'ing in Java?)
所以我按照这里的文档将XML字符串值与其他东西连接起来,结果得到以下代码:
//XML strings.xml <string name="start_next_act_string">The next activity has been scheduled to automatically launch in %1$d seconds!</string> //layout/activity_home.XML <TextView android:text="@string/start_next_act_string" android:layout_width="wrap_content" android:layout_height="wrap_content" /> //Home.java inside class, but outside oncreate int startNextActivityInSeconds = 10; //Home.java inside class and inside oncreate super.onCreate(savedInstanceState); Resources res = getResources(); String text = String.format(res.getString(R.string.start_next_act_string), startNextActivityInSeconds); setContentView(R.layout.activity_home);
但是在Android屏幕上会打印出来
下一个活动已安排在%1 $ d秒内自动启动!
而不是
下一个活动已安排在10秒内自动启动!
如何更新XML字符串以显示连续的字符串结果?
So I've followed the documentation here to concatenate XML string values with other things, and as a result have the following code:
//XML strings.xml <string name="start_next_act_string">The next activity has been scheduled to automatically launch in %1$d seconds!</string> //layout/activity_home.XML <TextView android:text="@string/start_next_act_string" android:layout_width="wrap_content" android:layout_height="wrap_content" /> //Home.java inside class, but outside oncreate int startNextActivityInSeconds = 10; //Home.java inside class and inside oncreate super.onCreate(savedInstanceState); Resources res = getResources(); String text = String.format(res.getString(R.string.start_next_act_string), startNextActivityInSeconds); setContentView(R.layout.activity_home);
However on the Android screen it prints out
The next activity has been scheduled to automatically launch in %1$d seconds!
rather than
The next activity has been scheduled to automatically launch in 10 seconds!
How do I update XML string such that it displays the concat'd string result?
原文:
最满意答案
您将需要使用IsolatedStorage ,例如:
放在文件顶部:
using System.IO.IsolatedStorage;
然后在你的方法中这样做:
using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { using (var istream = new IsolatedStorageFileStream("File.txt", FileMode.OpenOrCreate, store)) { using (var sw = new StreamWriter(istream)) { sw.Write("Some Stuff"); } } }
这个和其他操作的一个很好的例子和解释可以在这里找到: http : //msdn.microsoft.com/en-us/library/cc265154(v = VS.95).aspx#Y300
您可以使用Windows Phone 7 IsolatedStorageExplorer查看IsolatedStorage
一个开始文档的好地方: http : //msdn.microsoft.com/library/ff626516(v = VS.92).aspx
也在这里: http : //create.msdn.com/en-us/education/documentation
You will need to use IsolatedStorage, for example:
Place at the top of your file:
using System.IO.IsolatedStorage;
Then in your method do this:
using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { using (var istream = new IsolatedStorageFileStream("File.txt", FileMode.OpenOrCreate, store)) { using (var sw = new StreamWriter(istream)) { sw.Write("Some Stuff"); } } }
A great example and explanation of this and other operations can be found here: http://msdn.microsoft.com/en-us/library/cc265154(v=VS.95).aspx#Y300
You can look through your IsolatedStorage by using the Windows Phone 7 IsolatedStorageExplorer
A good place to start for documentation: http://msdn.microsoft.com/library/ff626516(v=VS.92).aspx
Also here: http://create.msdn.com/en-us/education/documentation
相关问答
更多-
如何 - Windows Phone 7?(How to - Windows Phone 7?)[2022-10-20]
大部分是 - 获取当前位置(cellid,mnc,mmc,lac,lat,lng) 大部分没有 - 读/写/删除/拦截SMS,CallLog,联系人,日历,文件,笔记 否 - 获取已安装的应用程序列表 是 - 使用SQLite 否 - 电子邮件和VPN配置 MOSTLY NO - 能够启用/禁用蓝牙,GPRS,无线网络 是 - 录音 是 - 加密 大多数不 - 控制手机配置文件 是 - JSON 大多数不 - 文件系统通知 MOSTLY YES - Get current location (cellid, ... -
我缺少.Net和VS2012扩展的代码合同: .Net的代码合同 - http://www.google.com/url?q=http%3A%2F%2Fvisualstudiogallery.msdn.microsoft.com%2F1ec7db13-3363-46c9-851f-1ce455f66970%3FSRC%3DVSIDE&sa=D&sntz= 1 USG = AFQjCNGLZoTI_GSQJfSfJP5JuSNvv8SlOw 代码合约编辑器扩展VS2012 - http://www.googl ...
-
是的。 Windows Phone Silverlight 8是Windows Phone 8.1发布后给予Windows Phone 8的名称。 还有Windows Phone Silverlight 8.1和Windows Phone 8.1 。 这两者之间的区别在于Windows Phone 8.1与Windows应用商店应用兼容,而Windows Phone Silverlight 8.1不兼容。 你可以在这里了解更多关于这个: http : //msdn.microsoft.com/en-us/l ...
-
如果没有看到您的实际代码,很难说出问题所在。 因此,我会提供另一种解决方案,而不是试图读懂你的想法。 我已经在Windows Phone上广泛使用了隔离存储,我已经学到了这一点。 世界上没有库,没有API,没有SDK,没有Web服务,错误报告比Windows手机上的隔离存储更糟糕。 一切都是无效访问或未经授权的访问与ZERO进一步的信息。 为了解决这个问题,我创建了一个DLL,它将对象序列化为隔离存储。 您所要做的就是将[DataContractAttribute]置于您的类名之上,将[DataMemebe ...
-
它通过将临时文件名更改为原始文件名即字符串tempJpeg来解决 It got solved by changing temporary file name to original file name i.e. string tempJpeg
-
FileStream非常慢?(Is FileStream very slow?)[2023-08-18]
我不知道性能问题(听起来很奇怪),但根本没有理由在这里使用StreamReader / StreamWriter ,因为您可以在二进制级别进行复制。 事实上,ISO映像不是文本 ,因此将其读入char数据很可能会破坏事物。 有关信息,即使您不想使用File.Copy ,您所需要的只是: using(var inFile = File.OpenRead(source)) using(var outFile = File.Create(destination)) { inFile.CopyTo(outF ... -
2014年4月11日发布的新版SQLite(3.8.3.1)应解决任何问题,最后:-)。 到目前为止,我没有遇到过同样的错误,所以我想它现在已经修复了。 http://www.sqlite.org/releaselog/3_8_3_1.html The new version of SQLite (3.8.3.1) that was released on 11th April 2014 should resolve any issues, finally :-) . So far I have not e ...
-
Mango确实是Windows Phone 7.5更新的代号。 Windows Phone 7.5中有许多新的API和功能,它带来了一个新的SDK(版本7.1)。 针对Windows Phone 7.0 SDK的应用在7.1下工作正常,但针对Windows Phone 7.1 SDK的应用需要运行Mango更新。 Windows Phone站点列出了Windows Phone 7.5(Mango更新)中的新功能, MSDN列出了7.0 SDK和7.1 SDK之间的API更改。 Mango was indee ...
-
由于Windows Phone应用程序是沙箱,因此通常使用Isolated Storage类来保存文件,而不是直接转到System.IO。 但既然你提到了关卡信息(编译到你的应用程序中?),也许以下链接会有所帮助: 如何在WP7应用程序中嵌入和读取文本文件? Since Windows Phone apps are sandboxed, you would typically use the Isolated Storage classes for saving files, and not go dire ...
-
您将需要使用IsolatedStorage ,例如: 放在文件顶部: using System.IO.IsolatedStorage; 然后在你的方法中这样做: using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { using (var istream = new IsolatedStorageFileStream("File.txt", FileMode.OpenOrCreate, store)) { ...