I’m currently trying to create an activity in Android Studio where if I press a specific combination of buttons, I can get a specific output based on the combination.
For example, there are 6 buttons where I can change the ImageView
and TextView
. With these buttons, I can change the shape and colour of an object.
-
SHAPE:
Square
,Triangle
,Circle
-
COLOUR:
Red
,Blue
,Green
On default, the ImageView
and TextView
will display a ‘Red Square’.
If I click on Triangle
, the ImageView
and TextView
will display a ‘Red Triangle’.
After that, if I click on Green
, the ImageView
and TextView
will display a ‘Green Triangle’.
And so on..
I’m quite a beginner at this and so far I only know how to do this if one button only has one output. Searched around and found that maybe I could use SharedPreferences
. Using this, If I exit the app and restarted it, it will still display the output from the last session. In this case, the ImageView
and TextView
will still display a ‘Green Triangle’. I thought that maybe I could implement this so I can store the data from the last button that was clicked. However, I’m still clueless.
Anyone that can help? Thanks in advance!
honey is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.