Bonjour,
Je cherche à afficher un tableau dynamique dans un dialog. J'ai donc créé un layout xml avec la description de mon tableau.
Voici le début du xml (le reste, c'est la même chose) :Dans mon code, j'initialise les TextView :
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"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TableRow> <TextView android:layout_marginLeft="10dip" android:text="Lu" android:typeface="monospace" android:textStyle="bold" android:textSize="20sp" android:padding="5dip" /> <TextView android:text="Ma" android:typeface="monospace" android:textStyle="bold" android:textSize="20sp" android:padding="5dip" /> <TextView android:text="Me" android:typeface="monospace" android:textStyle="bold" android:textSize="20sp" android:padding="5dip" /> <TextView android:text="Je" android:typeface="monospace" android:textStyle="bold" android:textSize="20sp" android:padding="5dip" /> <TextView android:text="Ve" android:typeface="monospace" android:textStyle="bold" android:textSize="20sp" android:padding="5dip" /> <TextView android:text="Sa" android:typeface="monospace" android:textStyle="bold" android:textSize="20sp" android:padding="5dip" /> <TextView android:text="Di" android:typeface="monospace" android:textStyle="bold" android:textSize="20sp" android:padding="5dip" /> </TableRow>Ensuite, je souhaite modifier les TextView :
Code : Sélectionner tout - Visualiser dans une fenêtre à part TextView d01 = (TextView)findViewById(R.id.x11);Malheureusement, le programme plante (NullPointerException) au niveau de d01.setText("01");
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 View messageView = getLayoutInflater().inflate(R.layout.mois, null, false); AlertDialog.Builder dialog = new AlertDialog.Builder(this); d01.setText("01"); dialog.setIcon(R.drawable.mois); dialog.setTitle(" Août 2010"); dialog.setNeutralButton("Suivant", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // action } }); dialog.setView(messageView); dialog.create(); dialog.show();
N'est-il pas possible de modifier les textview contenues dans un dialog ?
Partager