user1639529
user1639529

Reputation:

How to store and display the button names ( in different screens)that are clicked by user in android

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

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

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.

My problem is:

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

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.

Upvotes: 0

Views: 85

Answers (2)

user370305
user370305

Reputation: 109257

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

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

Update:

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().

Upvotes: 1

sabarish
sabarish

Reputation: 141

Better store the button name by String b1=button.getText().toString().a

Upvotes: 0

Related Questions