Skip to content
Extraits de code Groupes Projets
Valider 2c3ffe84 rédigé par Monnot's avatar Monnot
Parcourir les fichiers

Creation of Task class

parent 8523787a
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
package com.clemhaowen.dm_td2.tasklist
data class Task(
var id:String = "id",
var title:String = "Task",
var description:String = "description"
)
\ No newline at end of file
......@@ -5,17 +5,33 @@ import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.clemhaowen.dm_td2.R
class TaskListFragment : Fragment() {
private val taskList = listOf("Task 1", "Task 2", "Task 3")
//private val taskList = listOf("Task 1", "Task 2", "Task 3")
// TODO uncomment when Task is implemented
private val taskList = listOf(
Task(id = "id_1", title = "Task 1", description = "description 1"),
Task(id = "id_2", title = "Task 2"),
Task(id = "id_3", title = "Task 3")
)
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Pour une [RecyclerView] ayant l'id "recycler_view":
var recyclerView = view?.findViewById<RecyclerView>(R.id.fragment_tasklist_recyclerView)
recyclerView?.layoutManager = LinearLayoutManager(activity)
// TODO uncomment when TaskListAdapter is created
//recyclerView?.adapter = TaskListAdapter(taskList)
// En utilisant les synthetics, on écrit juste l'id directement (c'est magique ✨):
//R.id.fragment_tasklist_recyclerView.layoutManager = LinearLayoutManager(activity) // ça marche pas
return inflater.inflate(R.layout.fragment_task_list, container, false)
}
}
\ No newline at end of file
......@@ -2,9 +2,10 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/fragment_tasklist_recyclerView"
/>
</LinearLayout>
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter