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

后端 未结 2 1646
囚心锁ツ
囚心锁ツ 2021-01-28 08:16

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

2条回答
  •  日久生厌
    2021-01-28 08:29

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

提交回复
热议问题