Flowcki Posted November 15, 2010 Share Posted November 15, 2010 Bonjour, J'ai actuellement un fichier xml qui contient un LinearLayout en orientation vertical pour une listeview avec nom prénom et description et je voudrais que le nom et le prénom soit sur une seule ligne mais je n'arrive pas à les orienté en horizontal pour qu'ils se suivent. Voila mon fichier 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="wrap_content"> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical"> <TextView android:id="@+id/titre" android:text="Nom" android:layout_height="fill_parent" android:textSize="16px" android:textStyle="bold" android:layout_width="wrap_content"/> <TextView android:id="@+id/titre" android:text="Prénom" android:textSize="16px" android:textStyle="bold" android:layout_width="fill_parent" android:layout_height="fill_parent"/> <TextView android:id="@+id/description" android:text="Description" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </LinearLayout> </LinearLayout> Merci d'avance. Link to comment Share on other sites More sharing options...
cyrilbouisson@gmail.com Posted November 15, 2010 Share Posted November 15, 2010 Salut Tu n'as qu'à mettre le nom et prénom dans un autre LinearLayout avec une orientation horizontale... Ce second LinearLayout faisant partie du LinearLayout "vertical". Par exemple : <?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="wrap_content"> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical"> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/titre" android:text="Nom" android:layout_height="fill_parent" android:textSize="16px" android:textStyle="bold" android:layout_width="wrap_content"/> <TextView android:id="@+id/titre" android:text="Prénom" android:textSize="16px" android:textStyle="bold" android:layout_width="fill_parent" android:layout_height="fill_parent"/> </LinearLayout> <TextView android:id="@+id/description" android:text="Description" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </LinearLayout> </LinearLayout> Link to comment Share on other sites More sharing options...
Flowcki Posted November 15, 2010 Author Share Posted November 15, 2010 Merci ^^ C'est possible de mettre un espace entre le nom et le prénom ? Et je viens de m'apercevoir qu'avec un BaseAdapter j'ai une erreur dans le DDMS Caused by java.lang.NullPointerException (Main.java:22) : package com.codiiz.BaseAdapter; import java.util.ArrayList; import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.widget.ListView; public class Main extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ArrayList<Personne> listP = Personne.getPersonne(); PersonneAdapter adapter = new PersonneAdapter(this, listP); ListView listview = (ListView) findViewById(R.id.ListView01); listview.setAdapter(adapter); //ligne 22 } } Et je comprend pas pourquoi, j'ai beau chercher dans google je trouve pas et sur d'autre tuto utilisant BaseAdapter et il y a pas de problème de ce genre... Link to comment Share on other sites More sharing options...
cyrilbouisson@gmail.com Posted November 15, 2010 Share Posted November 15, 2010 Oui tu peux mettre un espace entre le nom et le prénom en jouant sur le "padding" des TextView (par exemple tu peux définir un "padding_left" sur le TextViex concernant le prénom) Link to comment Share on other sites More sharing options...
Flowcki Posted November 15, 2010 Author Share Posted November 15, 2010 D'accord merci ^^ Et pour l'erreur tu as une idée ? Ma classe Personne est pourtant correct et PersonneAdapter aussi, je comprend pas du tout pourquoi ça plante... Link to comment Share on other sites More sharing options...
cyrilbouisson@gmail.com Posted November 15, 2010 Share Posted November 15, 2010 Comme cela je ne sais pas trop mais est-ce que ta variable "listP" est bien initialisée (n'est-elle pas à nulle) ? Que te retourne "Personne.getPersonne()" ? Link to comment Share on other sites More sharing options...
Flowcki Posted November 15, 2010 Author Share Posted November 15, 2010 Ca retourne un ArrayList : public static ArrayList<Personne> getPersonne(){ ArrayList<Personne> listPers = new ArrayList<Personne>(); listPers.add(new Personne("test", "test", "Blabla")); listPers.add(new Personne("test", "test", "Blabla")); listPers.add(new Personne("test", "test", "Blabla")); return listPers; } Voila le topic dans la bonne catégorie sinon : J'ai même repris le code de développez.com et toujours pareil :( et leur source par contre fonctionne donc je comprend pas du tout. J'espère que tu pourra m'aider, depuis ce matin que je suis dessus. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.