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 (57.94 KiB) Viewed 42 times
Q1) Given the following excerpt of code, briefly explain when the method on TouchEvent() gets invoked. (5m) 1 2 3 @Override public boolean on TouchEvent(MotionEvent event) { Log.d(TAG, "onTouchEvent: "+event.getActionMasked()); return true; } 4 5 6 7 8 9 10 11 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 layout=findViewById(R.id.layout); outer-findViewById(R.id.view_out); inner=findViewById(R.id.view_inner); layout.setOnTouchListener(new View.OnTouchListener() { @Override public boolean on Touch(View view, MotionEvent motionEvent) { Log.d(TAG,"Layout: "+motionEvent.getActionMasked()); return layoutFlag; } }); outer.setOnTouchListener(new View.OnTouchListener() { @Override public boolean on Touch (View view, MotionEvent motionEvent) { Log.d(TAG, "Outer: "+motionEvent.getActionMasked()); return outerFlag; } }); inner.setOnTouchListener(new View.OnTouchListener() { @Override public boolean on Touch (View view, MotionEvent motionEvent) { Log.d(TAG, "Inner: "+motionEvent.getActionMasked(); return innerFlag; } }); 27 28 29 30 31 32 33 34 35 36 }
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply