如何存储和显示的按钮名称(在不同的屏幕)是由用户在Android的点击是由、按钮、屏幕、不同

2023-09-04 04:51:49 作者:掌心的温暖

在我的应用程序我有4个屏幕(屏幕截图1,画面2,画面3,screen4)

In my app I have 4 screens(screen1,screen2,screen3,screen4)

屏蔽1有3个按钮(B1,B2,B3) 画面2有3个按钮(B4,B5,B6) 屏幕3有3个按钮(B7,B8,B9)

Screen1 has 3 buttons(B1,B2,B3) Screen2 has 3 buttons(B4,B5,B6) Screen3 has 3 buttons(B7,B8,B9)

如果用户点击任何按钮,屏幕截图1然后屏幕2的呈现方式。如果用户点击任何按钮,画面2,然后画面3的呈现方式。

If a user clicks on any button in screen1 then screen2 is rendered. If a user clicks on any button in screen2 then screen3 is rendered.

我的问题是:

在screen4我要显示由用户点击按钮的名称。

In screen4 I have to display the button names that are clicked by user.

也就是说如果用户点击B2的屏幕截图1然后在画面2点击B6则在画面3点击B7,screen4的输出应该是:

i.e If a User clicks on B2 in screen1 then clicks on B6 in screen2 then clicks on B7 in screen3, the output of screen4 should be:

B2

B6

B7

我怎样才能做到这一点? 谢谢你在前进。

How can I do this? Thank you in advance.

推荐答案

或者使用意图putExtra()将值传递给每个活动或制作的 应用类 持有的价值是最好的选择。

Either Using Intent putExtra() to pass values to each Activity or Making Application Class which holds the Values is the best option.

您也可以使用共享preference 但我认为它做出困难的给你。

You can also use SharedPreference but I think its make difficult to you..

更新:

呵呵,我错过了你的问题不大,是如何存储

Oh, I missed your question little, with how to store,

您可以得到按钮的名称,比如,(也是唯一的实际可能有所不同)

You can get button's name like, (only Example Actual may different)

Button button1 = (Button)findViewById(R.id.button1);
String buttonName = button1.getText().toString().