Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

Students also viewed these Databases questions