简体   繁体   English

单击来自两个不同活动的两个单选按钮时,如何在新活动中显示文本?

[英]How to display text in a new activity when two radio buttons from two different activities are clicked?

I am using Java and Android Studio.我正在使用 Java 和 Android 工作室。 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.我有一个活动,其中包含 select 的几个选项,一旦选择其中一个,他们单击将它们带到下一个活动的按钮。 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?我怎样才能做到这一点?

You cannot declare a method inside another method.您不能在另一个方法中声明一个方法。 Put a closing brace after onCreate.在 onCreate 之后放置一个右大括号。

When you are opening a new activity, you are doing it with an Intent.当您打开一个新活动时,您是在使用 Intent 进行的。 Put the values you want to send (bool clicked) the new activity inside the intent将您要发送的值(单击布尔值)放入意图中的新活动

You can send some variable through intent and onCreate() method of the second activity, you can use that variable to differentiate your functionality.您可以通过第二个活动的意图和 onCreate() 方法发送一些变量,您可以使用该变量来区分您的功能。 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. 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 .

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 android 工作室中单击时,如何使单选按钮在另一个活动中显示文本? - How to make radio buttons display a text in another activity when clicked in android studio? 从Android中的两个不同活动打开时的不同活动行为 - Different Behaviors of Activity when Opened from two Different Activities in Android 两个按钮到两个不同活动的意图 - intent for two buttons to two different activities 如何使用按钮将String值从一个活动传递到两个不同的活动? - How do you pass String value using button from one activity to two different activities? 单击按钮时以及如何重新启动应用程序时如何交换两个整个活动,然后显示交换更改 - How to swap two whole activity when button is clicked and when application start again then display that swapping changes 将来自两个不同活动的两个值相加并显示另一个活动中的总计 - Adding two values from two different activities and displaying the total in a different activity 在Java中选中不同的单选按钮时,如何显示不同的消息? - How to display different messages when different radio buttons are checked in Java? 如何使用同一屏幕上的两个不同的按钮启动两个不同的活动? - how to launch two different activities with two different buttons which are in the same screen? 如何在两个活动之间显示不同的json数据? - how to display different json data between two activities? 如何同时将数据从一个活动传递到两个或多个活动? - How to pass data from one activity to two or more activities simultaneously?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM