ListActivity : ArrayAdapter
Bonjour,
je souhaite afficher une liste de tache mais j'ai une erreur à la ligne 22 : this,android.R.layout.simple_list_item_1,tableau_taches : Cannot resolve ArrayAdapter
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
public class MainActivity extends ListActivity {
Object[] tableau_taches = {
new Tache("Cours de programmation",4),
new Tache("Entraînement de natation",3),
new Tache("Faire une sieste",2),
new Tache("Prendre une douche",0),
new Tache("Ecouter des infos",1),
};
ListView l ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
l = getListView();
ArrayAdapter<Tache> adapter = new ArrayAdapter<Tache>(this,android.R.layout.simple_list_item_1,tableau_taches);
l.setAdapter(adapter);
}
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
public class Tache
{
String titre ;
int priorite ;
public Tache (String unTitre, int unePriorite)
{
titre = unTitre;
priorite = unePriorite;
}
public String getTitre() { return titre; }
public int getPriorite() { return priorite; }
} |
Code:
1 2 3 4 5 6 7 8
|
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/listView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" /> |