CS计算机代考程序代写 Java flex android 15/06/2021 Week 5: Workshop Quiz: Attempt review

15/06/2021 Week 5: Workshop Quiz: Attempt review
FIT2081 Mobile application development – S1 2021
Dashboard / My units / FIT2081_S1_2021 / Assessments / Week 5: Workshop Quiz
Started on State Completed on Time taken Grade
Print friendly format
Question 1
Monday, 29 March 2021, 10:16 PM Finished
Monday, 29 March 2021, 11:49 PM 1 hour 32 mins
6.44 out of 10.00 (64%)
Question 1
Complete
Mark 6.44 out of 10.00
1- What is the role of return true or false from the callback method onCreateOptionsMenu?
Using callback( ) method and if they return false, the menu will be created but when clicking on the menu it will do nothing so it will not open the menu. Because it specifies the actions for the contextual action bar, respond to click events on action items and deal with other lifecycle events for the action mode.
2- If you have a navigation view with 3 items, how many events handlers do you need to code to handle the click events from these four items? And Why?
When having 4 items in the navigation view, we should need to deal with each of them. Because when clicking on one of the items, it will actually inflate that particular fragment. We need to handle them separately because they are just like separate activities.
Comment:
(Q1=43% Q2=69% Q3=80% )
Question 2 Complete Not graded
https://lms.monash.edu/mod/quiz/review.php?attempt=19036416&cmid=8331151 1/4

15/06/2021 Week 5: Workshop Quiz: Attempt review
Question 2
3- Suppose you are trying to link a button to its event handler. Briefly explain two differences between implementing the OnClickListener and using the android:onClick attribute in the activities XML file.
Two differences between OnClickListener and android:onClick:
1. onClick is a function that gets called when someone clicks the button. However, OnclickListener is an interface that provides it more flexibility as any class could implement an interface.
2. onClick is easier to implement and takes one parameter as a view but implementing OnclickListener is a bit more difficult. OnclickListener is a bit more complex with respect to onClick
Question 3 Complete Not graded
Question 3
4- Assume you have a left to right drawer in your activity, write a java statement that closes it.
To close drawer, with id drawer_layout, Given statement for drawer, we simply call closeDrawers() method. The Java statement:
drawer.closeDrawers(GravityCompat.START);
OR
drawer.closeDrawers(GravityCompat.END);
Question 4 Complete Not graded
Question 4
5- Briefly describe the required steps to change the text colour of a listview from black to red.
Three steps:
1. Add any layout you want in the XML file.
https://lms.monash.edu/mod/quiz/review.php?attempt=19036416&cmid=8331151 2/4

15/06/2021 Week 5: Workshop Quiz: Attempt review
2. Add ListView in this android file.
3. Add TextView to display list in ListView and also add android:textColor=”#ff0000″ this line to change the text colour of ListView. When completing the above 3 steps, so it can change the text colour of listview from black to red.
Question 5 Complete Not graded
Question 5
6- Assume you have an activity with a listview (id=unitslist) in it. Develop a piece of code that adds the following items to the listview:
• Monash
• S1
• 2021
package com.example.workshop_w5;
import androidx.appcompat.app.AppCompatActivity; import android.widget.ListView;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import java.util.ArrayList; import java.util.List;
public class MainActivity extends AppCompatActivity { @Override
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
List unitsmess=newArrayList<>(); unitsmess.add(“Monash”); unitsmess.add(“S1”); unitsmess.add(“2021”);
ArrayAdapter adapter =newArrayAdapter<>(this,R.layout.unitlist,unitsmess);
https://lms.monash.edu/mod/quiz/review.php?attempt=19036416&cmid=8331151 3/4

15/06/2021 Week 5: Workshop Quiz: Attempt review
ListView unitList = (ListView) findViewById(R.id.unitslist);
unitList.setAdapter(adapter); }
}
◄ Week 4: Workshop Quiz
Jump to…
Week 6: Workshop Quiz ►
https://lms.monash.edu/mod/quiz/review.php?attempt=19036416&cmid=8331151 4/4