Question: In Android Studio, in Java: I have an ImageView and one textView in my XML. When I click on my ImageView, a variable is incremented.

In Android Studio, in Java:

I have an ImageView and one textView in my XML.

When I click on my ImageView, a variable is incremented. This variable is displayed on the textView.

Before the onCreate:

int add; TextView textView; ImageView imageView; 

and in my onCreate:

add = 0;

//Then I do findViewById for the textview and imageview

After that I make a imageView setOnClickListener:

imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { add++; textView.setText("Click #: " + add); } });

I need to make it so when I close out my emulator and relaunch it, the value of add is saved/stores and displays from before. After the emulator is reloaded, the variable should not display and reset to 0. It should display whatever the value was before the emulator was reloaded. I need the code for this in Java on Android Studio.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!