mirror of
https://github.com/LucasVbr/OutilCuisson.git
synced 2026-05-13 17:11:53 +00:00
utilisation ligne_liste.xml pour l'affichage des cuissons
This commit is contained in:
@@ -74,7 +74,7 @@ public class AfficherFragment extends Fragment {
|
|||||||
cuissonAffichees = new ArrayList<>();
|
cuissonAffichees = new ArrayList<>();
|
||||||
listeCuissons = view.findViewById(R.id.listeCuisson);
|
listeCuissons = view.findViewById(R.id.listeCuisson);
|
||||||
adapterCuissons = new ArrayAdapter<String>(getActivity(),
|
adapterCuissons = new ArrayAdapter<String>(getActivity(),
|
||||||
android.R.layout.simple_list_item_1, cuissonAffichees);
|
R.layout.ligne_liste, R.id.item_cuisson, cuissonAffichees);
|
||||||
listeCuissons.setAdapter(adapterCuissons);
|
listeCuissons.setAdapter(adapterCuissons);
|
||||||
registerForContextMenu(listeCuissons);
|
registerForContextMenu(listeCuissons);
|
||||||
|
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
package com.example.outilcuisson;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CuissonAdapter extends ArrayAdapter<Cuisson> {
|
|
||||||
|
|
||||||
private int identifiantVueItem;
|
|
||||||
|
|
||||||
|
|
||||||
public CuissonAdapter(@NonNull Context context, int vueItem, List<Cuisson> lesCuissons) {
|
|
||||||
super(context, vueItem,lesCuissons);
|
|
||||||
this.identifiantVueItem = vueItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
public View getView(int position, View uneVue, ViewGroup parent){
|
|
||||||
Cuisson unPlat = getItem(position);
|
|
||||||
LinearLayout vueItemListe;
|
|
||||||
|
|
||||||
if (uneVue == null) {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* la vue décrivant chaque item de la liste n'est pas encore créée
|
|
||||||
* Il faut désérialiser le layout correspondant à cette vue.
|
|
||||||
*/
|
|
||||||
LayoutInflater outil;
|
|
||||||
outil = (LayoutInflater)getContext()
|
|
||||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
||||||
vueItemListe = (LinearLayout) outil.inflate(identifiantVueItem,
|
|
||||||
parent, false);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
vueItemListe = (LinearLayout) uneVue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// on accède aux 2 widgets présents sur la vue
|
|
||||||
TextView vuePlat = vueItemListe.findViewById(R.id.item_plat);
|
|
||||||
TextView vueDuree = vueItemListe.findViewById(R.id.item_duree);
|
|
||||||
TextView vueDegres = vueItemListe.findViewById(R.id.item_degres);
|
|
||||||
|
|
||||||
// on place dans les 2 widgets les valeurs de l'item à afficher
|
|
||||||
vuePlat.setText(unPlat.getPlat());
|
|
||||||
vueDuree.setText(unPlat.getHeure());
|
|
||||||
vueDegres.setText(Integer.toString(unPlat.getDegree()));
|
|
||||||
return vueItemListe;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -11,23 +11,9 @@
|
|||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/item_plat"
|
android:id="@+id/item_cuisson"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:typeface="monospace"
|
android:typeface="monospace"
|
||||||
android:textStyle="bold"/>
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/item_duree"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:typeface="monospace"
|
|
||||||
android:textStyle="bold"/>
|
|
||||||
|
|
||||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/item_degres"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:typeface="monospace"
|
|
||||||
android:textStyle="bold"/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
Reference in New Issue
Block a user