简体   繁体   English

1 Button 2 activity in android studio using java

[英]1 Button 2 activity in android studio using java

How do I open another activity with the same button I clicked earlier?如何使用我之前单击的相同按钮打开另一个活动? For example, I click button A and goes to Activity 1 and I click home and click button A again and must go to Activity 2.例如,我单击按钮 A 并转到活动 1,然后单击主页并再次单击按钮 A,并且必须 go 到活动 2。

I tried putting id on button in xml and call different activity on its java.我尝试将 id 放在 xml 的按钮上,并在其 java 上调用不同的活动。

Imagine if the button is from HomeActivity,let the launcher activity pass an ExtraKey to the HomeActivity and again another ExtraKey at the OnBackPressed of the Activity you are navigating to after clicking the button.Set the onClickListner according to the String passed by those activities.想象一下,如果按钮来自 HomeActivity,让启动器活动将一个 ExtraKey 传递给 HomeActivity,然后在单击按钮后导航到的活动的OnBackPressed处再次传递另一个 ExtraKey。根据这些活动传递的字符串设置 onClickListner。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM