Answered step by step
Verified Expert Solution
Question
1 Approved Answer
i need help fixing my code. the problem is The functionality of the buttons: Count: Adds 1 to the current count Double: Doubles the current
i need help fixing my code. the problem is The functionality of the buttons:
Count: Adds to the current count
Double: Doubles the current count value when pressed
Reset: Sets the count value back to
Toast: Displays a toast message of your choice
Toggle: Turns the background image's visibility from VISIBLE to GONE and when pressed again it changes it from GONE to VISIBLE
Additional Requirements
Adding an ImageView that displays behind the count text This is what the Toggle buttons change the visibility of
Change the name of the app in the manifest file and make it "Layout App"
At least one onClick method should be attached in the onCreate method with an anonymous function or lambda expression
The TOAST and TOGGLE buttons are inside a linearLayout horizontal to achieve the sidebyside look hint: layoutweight is used
All displayed text should be a String resource rather than a hardcoded String
A screenshot image of the completed app, looking similar to the one above, is to be added to your zipped folder my code is this and i already have the activitymain and strings file just need the java code. buttons:
private int count ;
private ImageView backgroundImage;
@Override
protected void onCreateBundle savedInstanceState
super.onCreatesavedInstanceState;
setContentViewRlayout.activitymain;
Initialize views
TextView countText findViewByIdRidcountText;
Button btnCount findViewByIdRidbtnCount;
Button btnDouble findViewByIdRidbtnDouble;
Button btnReset findViewByIdRidbtnReset;
Button btnToast findViewByIdRidbtnToast;
Button btnToggle findViewByIdRidbtnToggle;
Set onClick listeners
btnCount.setOnClickListenerv
count;
countText.setTextgetStringRstring.countdefaulttext, count;
;
btnDouble.setOnClickListenerv
count ;
countText.setTextgetStringRstring.countdefaulttext, count;
;
btnReset.setOnClickListenerv
count ;
countText.setTextgetStringRstring.countdefaulttext, count;
;
btnToast.setOnClickListenerv showToastgetStringRstring.toastmessage;
btnToggle.setOnClickListenerv toggleVisibility;
private void showToastString message
Toast.makeTextthis message, Toast.LENGTHSHORTshow;
private void toggleVisibility
int visibility backgroundImagegetVisibility View.VISIBLE View.GONE : View.VISIBLE;
backgroundImage.setVisibilityvisibility;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started