Aller au contenu
View in the app

A better way to browse. Learn more.

Forum de Frandroid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Orientation TextView

Featured Replies

Posté(e)

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.

Modifié par R-transat

Posté(e)

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>

Posté(e)
  • Auteur

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...

Modifié par R-transat

Posté(e)
  • Auteur

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...

Posté(e)
  • Auteur

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.

Modifié par R-transat

Archivé

Ce sujet est désormais archivé et ne peut plus recevoir de nouvelles réponses.

Account

Navigation

Rechercher

Rechercher

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.