如何在android中调用activiy本身
基本上我正在做一个测验应用程序,我需要将一个问题专用于一页,用户应该能够翻阅页面来完成一个测验。我提出的想法是为所有问题保留一个单例类,并让一个活动每次针对一个问题调用自身,并根据该问题动态生成不同的内容。但是如何实现这样的事情呢?我可以使用意图来调用活动本身吗?或者应该有其他更好的解决方案吗?谢谢
Basically I am doing a quiz app, I need to dedicate one question to one page, user should be able to flip through the pages to finish one quiz. My proposed idea is to hold a singleton class for all the questions, and have an activity call itself each time for a question, and generate different content according to that question dynamically.But how would one achieve such thing? Can I use intent to call an activity itself? or should there be some other better solutions? thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据您正在讨论的问题数量,完成您想要完成的任务的最简单方法是将所有问题加载到视图中并将它们添加到 ViewFlipper。那么,您只需要一项活动,就可以使用 ViewFlipper 为问题之间的转换设置动画。
Depending on how many questions you're talking about, the easiest way to do what you're trying to accomplish would be to load up all of your questions into Views and add them to a ViewFlipper. You'd only need one activity, then, and you can animate the transitions between the questions with the ViewFlipper.
您将使用 startActivity();或 startActivityForResult();取决于你到底想做什么。请阅读此处
You would use startActivity(); or startActivityForResult(); depending on what exactly you wanted to do . Read Here