15/06/2021 Week 6: Workshop Quiz: Attempt review
FIT2081 Mobile application development – S1 2021
Dashboard / My units / FIT2081_S1_2021 / Assessments / Week 6: Workshop Quiz
Started on Monday, 12 April 2021, 4:46 PM
State Finished
Completed on Monday, 12 April 2021, 6:53 PM
Time taken 2 hours 6 mins
Grade 9.68 out of 10.00 (97%) Print friendly format
Question 1
Complete
Mark 9.68 out of 10.00
Question 1
1)- Rewrite the class Week6Adapter such that it becomes a RecyclerView Adapter that shows the content of the array list ‘names’ in a recycler view using the card layout week6_name_card.xml. The adapter must bind the two attributes of the PersonName class into the two text views that are declared in the card layout.
package com.example.week6adapter;
import android.util.Log;
import android.view.LayoutInflater; import android.view.View;
import android.view.ViewGroup; import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
public class Week6Adapter extends RecyclerView.Adapter
ArrayList
thi
https://lms.monash.edu/mod/quiz/review.php?attempt=19213857&cmid=8331152 1/4
15/06/2021 Week 6: Workshop Quiz: Attempt review
this.names = names; }
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.week6_name_card, parent,false);
ViewHolder viewHolder = new ViewHolder(v); Log.d(“week6App”,”onCreateViewHolder”); return viewHolder;
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
holder.firstname_id.setText(names.get(position).getFirstName()); holder.lastname_id.setText(names.get(position).getLastName()); Log.d(“week6App”,”onBindViewHolder”);
}
@Override
public int getItemCount() {
return names.size(); }
public class ViewHolder extends RecyclerView.ViewHolder{ public TextView firstname_id;
public TextView lastname_id;
public ViewHolder(@NonNull View itemView) { super(itemView);
} }
}
firstname_id = itemView.findViewById(R.id.firstname_id); lastname_id = itemView.findViewById(R.id.lastname_id);
https://lms.monash.edu/mod/quiz/review.php?attempt=19213857&cmid=8331152 2/4
15/06/2021 Week 6: Workshop Quiz: Attempt review
Comment:
(Q1=100% Q2=100% Q3=83% )
Question 2 Complete Not graded
Question 2
2)- Briefly explain two differences between Fragments and Activities.
1. Activities can represent the full screen while fragments is a portion of UI in an activity. Activity can exist independently without other activities, while fragments must always be a part of an activity and it can’t exist independently.
2. Activity contains 0 or multiple fragments. Fragments can be reused in multiple activities. In addition, a fragment can be added or removed while the activity is running.
Question 3 Complete Not graded
Question 3
3)- Briefly explain the data type and the role of param1, param2, and param3 in the following statement: getSupportFragmentManager().beginTransaction().replace(param1,param2).addToBackStack(param3).commit(); replace(param1,param2):
Param1 is the FrameLayout that can be used to hold a fragment, which is added or replaced by the Param2. Param1’s data type will be layout. Param2’s data type will be Fragment and it has the role is to display an UI. addToBackStack(param3):
Param3 is the name of the transaction/back stack state that can be saved in the back stack.
Because this part means that the transaction will be remembered after it is committed and it can reverse its operation when later popped off the stack.
Its data type is String.
Question 4
https://lms.monash.edu/mod/quiz/review.php?attempt=19213857&cmid=8331152 3/4
15/06/2021 Week 6: Workshop Quiz: Attempt review
Question 4
Not answered Not graded
Question 4
Question 5 Not answered Not graded
Question 5
◄ Week 5: Workshop Quiz
Jump to…
Week 7: Workshop Quiz ►
https://lms.monash.edu/mod/quiz/review.php?attempt=19213857&cmid=8331152 4/4