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.

ListView, BaseAdapter et vue qui ne change pas.

Featured Replies

Posté(e)

Bonsoir,

 

J'utilise une ListView pour lister une série d'objet Media de ma conception.

J'ai créé une Adapter qui étend BaseAdapter dont voici la fonction getView() :

@Override
        public View getView(int position, View convertView, ViewGroup parent) {
                View rootView = LayoutInflater.from(mContext).inflate(R.layout.simple_item, parent, false);
               
                TextView txtSimpleItem2 = (TextView) rootView.findViewById(R.id.textSimpleItem2);
                TextView txtSimpleItem = (TextView) rootView.findViewById(R.id.txtSimpleItem);
               
                Media media = getItem(position);
                txtSimpleItem2.setText(Utilities.REMOTE_URL + media.getPath());
                txtSimpleItem.setText(media.getName());
               
                return rootView;
        }

J'utilise dans cette methode le fichier simple_item.xml :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="vertical"
   android:padding="10dp" >
 
    <TextView
       android:id="@+id/txtSimpleItem"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:textSize="18sp" />

   <TextView
       android:id="@+id/textSimpleItem2"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:textSize="18sp" />
 
</LinearLayout>

Jusque là, ma ListView fonctionne à merveille en affichant correctement ma liste de Media de cette façon :

 

Image1

http://......./image1.png

-----------------------------------------------------------------

Image2

http://......./image2.png

 

Mon problème se situe lorsque je modifie l'ordre des TextView dans le fichier XML :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="vertical"
   android:padding="10dp" >
 
    <TextView
       android:id="@+id/textSimpleItem2"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:textSize="18sp" />
 
    <TextView
       android:id="@+id/txtSimpleItem"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:textSize="18sp" />
 
</LinearLayout>

Aucun changement ne se produit au niveau de la ListView !

La structure reste la même :

 

Image1

http://......./image1.png

-----------------------------------------------------------------

Image2

http://......./image2.png

 

Je ne comprend vraiment pas d'où peut venir le souci. J'ai testé sur plusieurs versions d'Android, sur plusieurs appareils. J'ai buildé l'application sur plusieurs postes différents, j'ai toujours le même problème.

 

EDIT : Le changement ne se fait que si je change l'un des ID.

Si vous avez une idée, vous me sauveriez la vie.

 

Merci d'avance.

 

Ivelfan

Modifié par Ivelfan

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.