英文:
How to display text in a new activity when two radio buttons from two different activities are clicked?
问题
我正在使用Java和Android Studio。我有一个活动,里面有几个选项可供选择,一旦选定其中一个选项,用户点击按钮将会进入下一个活动。他们再次执行相同的操作,但这次当用户点击按钮时,它将带他们进入一个新的活动,在该活动中显示基于之前点击的两个单选按钮的结果。我应该如何实现这个功能?
英文:
I am using Java and Android Studio. I have one activity with a few options to select from, and once one of them is selected, they click the button that takes them to the next activity. They do the same thing again except this time when the user clicks the button it takes them to a new activity where it displays the results based on the two radio buttons clicked previously. How can I do this?
答案1
得分: 0
不能在另一个方法内声明方法。在 onCreate 后放置一个闭合括号。
当你打开一个新的活动时,要使用 Intent。将要发送的值(bool clicked)放入意图内。
英文:
You cannot declare a method inside another method. Put a closing brace after onCreate.
When you are opening a new activity, you are doing it with an Intent. Put the values you want to send (bool clicked) the new activity inside the intent
答案2
得分: 0
通过意图(intent)和第二个活动的onCreate()方法,您可以传递一些变量,然后可以使用该变量来区分您的功能。
这个视频演示了单选按钮的功能:https://youtu.be/zJG9Prn3vZ0
在这个视频中,您可以了解如何将参数传递给另一个活动:https://youtu.be/OMCctaE66b8
希望这能帮助您解决问题。
英文:
You can send some variable through intent and onCreate() method of the second activity, you can use that variable to differentiate your functionality.
This video demonstrates the functionality of the radio button: https://youtu.be/zJG9Prn3vZ0
In this video you can know how to pass arguments to another activity: https://youtu.be/OMCctaE66b8
Hope that helps you to solve your problem.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论