可以在 SurfaceView 中使用 OutputStreamWriter 吗?
我想从 SurfaceView 将高分写入文件。这可能吗? 我有这段代码:
OutputStreamWriter out = new OutputStreamWriter(
openFileOutput("highscore.txt",0));
但它告诉我,“BoardView”类型的方法 openFileOutput(string, int) 未定义(boardview 是我的 Surfaceview)
有什么建议吗?
I would like to write a highscore out to a file from a SurfaceView. Is this possible?
I have this piece of code:
OutputStreamWriter out = new OutputStreamWriter(
openFileOutput("highscore.txt",0));
But it tells me that the method openFileOutput(string, int) is undefined for the type "BoardView" (boardview is my surfaceview)
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
openFileOutput
是 context 的一种方法,因此您应该向表面视图传递一个上下文(例如您的 Activity),并将其用作yourActivityObject.openFileOutput("highscore. txt",0)
使用此方法。openFileOutput
is a method of context, so you should pass your surface view a context (your activity for example) and use it asyourActivityObject.openFileOutput("highscore.txt",0)
to use this method.