Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following piece of code is designed to show a toast with each Action Up event. But, it shows nothing. Find and explain the

The following piece of code is designed to show a toast with each Action Up event. But, it shows nothing.

The following piece of code is designed to show a toast with each Action Up event. But, it shows nothing. Find and explain the problem, then fix it. (7m) 1view.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch (View v, Motion Event event) { boolean flag=true; int action event.getActionMasked(); if(action == Motion Event.ACTION_DOWN) { //some code goes here flag- ! flag; 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16}); } } if(action == MotionEvent.ACTION_UP){ Toast.makeText (self, "Action UP", Toast.LENGTH_SHORT).show(); flag- ! flag; } return flag;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Problem Explanation The issue in the provided code lies in the incorrect use of the flag variable an... 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_2

Step: 3

blur-text-image_3

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

Smith and Roberson Business Law

Authors: Richard A. Mann, Barry S. Roberts

15th Edition

1285141903, 1285141903, 9781285141909, 978-0538473637

More Books

Students also viewed these Programming questions