Bonjour,
j'ai un petit problème, il y a quelques semaine avec ce code j'arrivai lorsque je cliqué sur mon image a afficher un Toast (pop up) qui s'afficher correctement avec des retours a la ligne, mais je viens d'essayer à nouveau est maintenant ma pop up s'affiche toute blanche car elle n'aime pas le caractère '\n', quelqu'un a t il une solution pour que je puisse effectuer mon retour à la ligne correctement, voici mon code :
et voici mon fichier xml qui me permet de personnaliser ma pop up :
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 ImageView image = (ImageView) Activity1.layout .findViewById(R.id.image); image.setImageResource(R.drawable.help); TextView text = (TextView) Activity1.layout .findViewById(R.id.text); text.setText(" Nom de l'élément : " + element.getNom() + "\n" + "prenom : " + element.getPrenom() + "\n" + "age: " + element.getAge()); text.setBackgroundColor(Color.WHITE); /** Toast **/ Toast toast = new Toast(Activity1.appContext); toast.setDuration(Toast.LENGTH_SHORT); toast.setGravity(Gravity.LEFT | Gravity.TOP, (int) (element.getCenterElement().x + 30), (int) (element.getCenterElement().y + 30)); toast.setView(Activity1.layout); toast.show();
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 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/custom_toast_layout_id" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/my_border" android:orientation="horizontal" android:padding="5dp" > <ImageView android:id="@+id/image" android:contentDescription="@string/marqueurInfo" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_marginRight="5dp" /> <TextView android:inputType="textMultiLine" android:id="@+id/text" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" android:textColor="@color/tabDark" android:textSize="12dp" /> </LinearLayout>
Partager