skywallker Posted February 16, 2013 Share Posted February 16, 2013 Bonjour J'ai un probléme consernant ma ListView Je ne trouve pas l'erreur merci de votre aide XML itemliste.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="match_parent" android:orientation="horizontal" > <LinearLayout android:layout_width="fill_parent" android:layout_height="80dp" android:orientation="horizontal" > <ImageView android:id="@+id/itemlistimage" android:layout_width="60dp" android:layout_height="fill_parent" android:src="@drawable/anneau" /> <TextView android:id="@+id/itemlisttext" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="description" android:gravity="center" /> </LinearLayout> </LinearLayout> XML:jim.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <ListView android:id="@+id/list" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > </ListView> </LinearLayout> Mon activity : package Citation.movies; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import Citation.movies.BDD.BDDF; import Citation.movies.BDD.QuoteFilm; import android.app.Activity; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.ListView; import android.widget.SimpleAdapter; import android.widget.TextView; public class CitationActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.jim); ArrayList<HashMap<String, String>> listItem = new ArrayList<HashMap<String, String>>(); ListView lv = (ListView) findViewById(android.R.id.list); HashMap<String, String> map; /********* préanbule ************************/ map = new HashMap<String, String>(); // map.put("itemlistimage", String.valueOf(R.drawable.anneau)); map.put("itemlisttext", "Editeur de texte"); listItem.add(map); map = new HashMap<String, String>(); // map.put("itemlistimage", String.valueOf(R.drawable.anneau)); map.put("itemlisttext", "Tableur"); listItem.add(map); map = new HashMap<String, String>(); // map.put("itemlistimage", String.valueOf(R.drawable.anneau)); map.put("itemlisttext", "Logiciel de présentation"); listItem.add(map); SimpleAdapter mSchedule = new SimpleAdapter(this, listItem, R.layout.itemliste, new String[] { "itemlisttext" }, new int[] { R.id.itemlisttext }); lv.setAdapter(mSchedule); } } Dans les log le probléme viens de "lv.setAdapter(mSchedule);" merci de vos réponse Link to comment Share on other sites More sharing options...
chpil Posted February 18, 2013 Share Posted February 18, 2013 Et quelle erreur as-tu précisemment ? quelle exception se produit ? tu peux être plus précis ? Link to comment Share on other sites More sharing options...
AndroWiiid Posted February 26, 2013 Share Posted February 26, 2013 Bonjour, Comme l'indique chpil, faudrait avoir ton code d'erreur que tu trouveras dans ton LogCat. Cela dit, j'ai remarqué une erreur évidente qui est la suivante : ListView lv = (ListView) findViewById(android.R.id.list); Tu vas chercher la classe R d'android pour récupérer l'id de liste. Chose qui n'est pas correcte puisque tu veux aller chercher l'identifiant de ta liste que tu as déclaré dans ton fichier XML. Tu dois donc changer cette ligne par : ListView lv = (ListView) findViewById(R.id.list); Cela dit, c'est peut-être pas la seule erreur. Pour nous aider à t'aider, il faudrait avoir ton erreur. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.