Bonjour,

C'est la première fois que j'écris sur ce forum et peut-être la première fois que j'écris sur un forum pour avoir de l'aide ...
J'ai un soucis qu'il me semble avoir déjà rencontré un jour mais je n'arrive plus à corriger, il me semble que c'est dû à un recalcul total des layouts mais je ne suis pas sûr :
Quand j'affiche un layout avec plus de 50 layouts (avec un scroll en parent) la rotation de l'écran met environ 5 secondes ainsi que l'affichage du clavier (qui redimensionne donc la fenêtre).
Les layouts se placent dynamiquement dans liste_top50 (LinearLayout)
Ces layouts sont "groupe_pistes" qui sont eux aussi complété par des "piste"

Le tout est généré en Inflater.

Voici le dessin de tout ça :
activity_main.xml :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
        <RelativeLayout
            android:id="@+id/pnl_top50"
            android:visibility="invisible"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >
 
            <com.easy2soft.musiques.Scolleur
                android:id="@+id/parent_liste_top50"
                android:layout_width="match_parent"
                android:layerType="hardware"
                android:layout_height="match_parent" >
 
                <LinearLayout
                    android:id="@+id/liste_top50"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    android:orientation="vertical" >
 
                </LinearLayout>
            </com.easy2soft.musiques.Scolleur>
 
        </RelativeLayout>
groupe_piste.xml :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
29
30
 
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="10dp"
     >
    <TextView
        android:id="@+id/titre_groupe"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:textColor="#489c23"
        android:textSize="18dp"
        android:background="@drawable/bg_titre_groupe"
        android:text="# (2 pistes)" />
 
    <LinearLayout
        android:id="@+id/liste_groupe"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_marginTop="5dp"
        android:layout_below="@+id/titre_groupe"
        android:orientation="vertical" >
 
    </LinearLayout>
 
</RelativeLayout>
piste.xml :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
 
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:hapticFeedbackEnabled="true"
    android:clickable="true"
    android:longClickable="true"
    android:soundEffectsEnabled="true"
    android:background="@drawable/bg_item"
    >
 
    <ImageView
        android:id="@+id/piste_pochette"
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:layout_margin="4dp"
        android:background="#489c23"
        android:padding="0dp"
        android:scaleType="centerCrop"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:src="@drawable/ic_launcher" />
 
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="64dp"
        android:layout_marginRight="4dp"
        android:layout_alignTop="@+id/piste_pochette"
        android:layout_toRightOf="@+id/piste_pochette"
        android:orientation="horizontal"
         >
 
        <LinearLayout
            android:id="@+id/piste_champs"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginRight="64dp"
            android:orientation="vertical" >
 
            <TextView
                android:id="@+id/piste_titre"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textStyle="bold"
                android:textColor="#030303"
                android:ellipsize="end"
                android:lines="1"
                android:textSize="16dp"
                android:text="01 California Gurls" />
 
            <TextView
                android:id="@+id/piste_auteur"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="#363636"
                android:textSize="14dp"
                android:layout_marginTop="-1dp"
                android:ellipsize="end"
                android:lines="1"
                android:text="Katy Perry" />
            <TextView
                android:id="@+id/piste_infos"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="#363636"
                android:textSize="14dp"
                android:layout_marginTop="-1dp"
                android:ellipsize="end"
                android:lines="1"
                android:text="4.54Mo / 192K" />
 
        </LinearLayout>
 
        <LinearLayout
            android:id="@+id/piste_actions"
            android:layout_width="64dp"
            android:layout_height="match_parent"
            android:layout_gravity="right"
            android:layout_marginLeft="-64dp"
            android:visibility="invisible"
            android:orientation="horizontal" >
 
            <ImageView
                android:id="@+id/piste_btn_download"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:background="@drawable/bg_icon"
                android:padding="5dp"
                android:src="@android:drawable/stat_sys_download_done" />
            <ImageView
                android:id="@+id/piste_btn_play"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:background="@drawable/bg_icon"
                android:padding="3dp"
                android:src="@android:drawable/ic_media_play" />
 
        </LinearLayout>
 
    </LinearLayout>
 
    <TextView
        android:id="@+id/piste_url_pochette"
        android:visibility="invisible"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="" />
 
</RelativeLayout>
Morceau du code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
 
										final GroupeMusic grp=new GroupeMusic(obj.getString("titre"));
										grp.setPistes(obj.getJSONArray("pistes"));
										runOnUiThread(new Runnable() {
 
											@Override
											public void run() {
												// TODO Auto-generated method stub
												liste.addView(grp.getLayout());												
											}
										});
Class GroupeMusic :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
 
	class GroupeMusic
	{
		private RelativeLayout groupe=null;
		public GroupeMusic()
		{
			init();
		}
		public GroupeMusic(String libelle)
		{
			init();
			setLibelle(libelle);
		}
		@SuppressLint("NewApi")
		private void init()
		{
			groupe=(RelativeLayout)getLayoutInflater().inflate(R.layout.groupe_piste, null);
			/*
			RelativeLayout.LayoutParams lp=new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);
			lp.setMargins(10, 10, 10, 10);
			groupe.setLayoutParams(lp);
			*/
		}
		public void clearPistes()
		{
			((LinearLayout)groupe.findViewById(R.id.liste_groupe)).removeAllViews();
		}
		public void addPiste(final String titre, final String auteur,final  String infos, final String id,final String pochette)
		{
			new Thread(new Runnable() {
 
				@Override
				public void run() {
					// TODO Auto-generated method stub
					final RelativeLayout tmp=(RelativeLayout)getLayoutInflater().inflate(R.layout.piste, null);
					tmp.setOnClickListener(new View.OnClickListener() {
 
						@Override
						public void onClick(View v) {
							// TODO Auto-generated method stub
							lireAudio(v.getId()-1000,((TextView)v.findViewById(R.id.piste_auteur)).getText().toString(),((TextView)v.findViewById(R.id.piste_titre)).getText().toString(),((TextView)v.findViewById(R.id.piste_url_pochette)).getText().toString());
						}
					});
					tmp.setId(Integer.parseInt(id)+1000);
					((TextView)tmp.findViewById(R.id.piste_url_pochette)).setText(Constantes.serveur+"/pochette-"+pochette+".png");
					((TextView)tmp.findViewById(R.id.piste_titre)).setText(titre);
					((TextView)tmp.findViewById(R.id.piste_auteur)).setText(auteur);
					((TextView)tmp.findViewById(R.id.piste_infos)).setText(infos);
					pochettes.add(Constantes.serveur+"/pochette-"+pochette+".png");
					Log.i("addPiste", "add : "+pochette+" ("+pochettes.size()+")");
					runOnUiThread(new Runnable() {
 
						@Override
						public void run() {
							// TODO Auto-generated method stub
							((LinearLayout)groupe.findViewById(R.id.liste_groupe)).addView(tmp);
 
						}
					});
					try {
						Thread.sleep(100);
					} catch (InterruptedException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					//new Images(((ImageView)tmp.findViewById(R.id.piste_pochette))).execute(Constantes.serveur+"/pochette-"+pochette+".png");
				}
			}).start();
		}
		public void setPistes(final JSONArray pistes)
		{
			clearPistes();
			new Thread(new Runnable() {
 
				@Override
				public void run() {
					// TODO Auto-generated method stub
					for(int i=0;i<pistes.length();i++)
					{
						JSONObject piste = null;
						try {
							piste = pistes.getJSONObject(i);
						} catch (JSONException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
						try {
							addPiste(piste.getString("titre"),piste.getString("auteur"),piste.getString("infos"),piste.getString("id"),piste.getString("url_pochette"));
						} catch (JSONException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}					
				}
			}).start();
 
		}
		public void setLibelle(String libelle)
		{
			((TextView)groupe.findViewById(R.id.titre_groupe)).setText(libelle);
		}
		public RelativeLayout getLayout()
		{
			return groupe;
		}
	}
Sinon il y-a un autre problème, c'est le temps de création de ces layouts mais ça je pense savoir que c'est ma méthode qui est un peu barbare mais je pense pouvoir m'en sortir...

Merci d'avance pour votre aide.

[SDK Android 4.4, appareil utilisé pour les tests : Samsung Galaxy Note 3]