Java

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Java

Post by answerhappygod »

Java
Java 1
Java 1 (29.49 KiB) Viewed 30 times
Q3) 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) 6 7 8 1 view.setOnTouchListener(new View.OnTouchListener() { 2 @Override 3 public boolean on Touch(View v, MotionEvent event) { 4 boolean flag=true; 5 int action = event.getActionMasked(); if(action == MotionEvent.ACTION_DOWN) { // some code goes here flag=!flag; } if(action == MotionEvent. ACTION_UP){ Toast.makeText(self, "Action UP", Toast.LENGTH_SHORT).show(); 12 flag=!flag; 13 } 14 return flag; 15 } 16}); 9 10 11
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply