15/06/2021 Week 11: Workshop Quiz: Attempt review
FIT2081 Mobile application development – S1 2021
Dashboard / My units / FIT2081_S1_2021 / Assessments / Week 11: Workshop Quiz
Started on Monday, 17 May 2021, 8:24 PM
State Finished
Completed on Monday, 17 May 2021, 10:53 PM
Time taken 2 hours 28 mins
Grade 6.92 out of 10.00 (69%) Print friendly format
Question 1
Complete
Mark 6.92 out of 10.00
Question 1
Q1 – Briefly explain the benefit of an ID and an index for each pointer in Android.
Each pointer gets a unique ID during the gesture’s lifetime and it is used to track the pointers within the gesture. This ID is generated once the pointer touches the screen and joins the gesture. The pointer index of a pointer can change from one event to the next but the pointer id of a pointer is guaranteed to remain constant as long as the pointer remains active.
A MotionEvent effectively stores information about each pointer in an array. The index of a
pointer is its position within this array. Most of the MotionEvent methods, which can use to interact with pointers take the pointer index as a parameter, not the pointer ID.
Comment:
(Q1=100% Q2=100% Q3=47% )
Question 2 Complete Not graded
https://lms.monash.edu/mod/quiz/review.php?attempt=19982134&cmid=8331157 1/4
15/06/2021 Week 11: Workshop Quiz: Attempt review
Question 2
Q2- What will happen if the onTouch() callback returns false instead of true?
If the onTouch( ) callback return false then the touch event will be passed to the next View further up in the view hierarchy and you will receive no follow-up calls. The touch event will continue to be passed further up the view hierarchy until someone consumes it.
Question 3 Complete Not graded
Question 3
Q3 – Update the following piece of code such that it displays a toast that shows the number of double-tap gestures that occurred on the layout ‘main_layout’ so far.
packagecom.fit2081.week11workshop;
import androidx.appcompat.app.AppCompatActivity; import androidx.core.view.GestureDetectorCompat;
import android.app.Activity;
import android.os.Bundle;
import android.view.GestureDetector; import android.view.MotionEvent;
import android.view.ScaleGestureDetector; import android.view.View;
import android.widget.TextView;
public class SampleActivity extends Activity implements OnDoubleTapListener,OnGestureListener {
private GestureDetectorCompat mDetector; private ScaleGestureDetector mScaleDetector;
@Override
protected void onCreate(Bundle savedInstanceState) {
https://lms.monash.edu/mod/quiz/review.php?attempt=19982134&cmid=8331157 2/4
15/06/2021 Week 11: Workshop Quiz: Attempt review
super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
mDetector = new GestureDetectorCompat(this, this); mScaleDetector = new ScaleGestureDetector(this, this); mDetector.setOnDoubleTapListener(this);
View layout=findViewById(R.id.main_layout); layout.setOnTouchListener(this);
}
@Override
public boolean onDoubleTap(MotionEvent e) {
if(e.getAction()==1) {
Toast.makeText(getBaseContext(),”onDoubleTap”, Toast.LENGTH_LONG).show();
}
return true;
}
@Override
public boolean onDoubleTapEvent(MotionEvent e) {
if(e.getAction()==1) {
Toast.makeText(getBaseContext(), “onDoubleTapEvent”, Toast.LENGTH_LONG).show();
}
return true; }
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
if(e.getAction()==1) {
Toast.makeText(getBaseContext(), “onSingleTapConfirmed”, Toast.LENGTH_LONG).show();
}
return true; }
}
Question 4 Not answered Not graded
https://lms.monash.edu/mod/quiz/review.php?attempt=19982134&cmid=8331157 3/4
15/06/2021 Week 11: Workshop Quiz: Attempt review
Question 4
Question 5 Not answered Not graded
Question 5
◄ Week 10: Workshop Quiz
Jump to…
Week 12: Workshop Quiz ►
https://lms.monash.edu/mod/quiz/review.php?attempt=19982134&cmid=8331157 4/4