Salut à tous, j'ai eu une erreur nullpointerexception assez bizarre today :p. En fait j'utilise un PagerAdapter et depuis je galère à accéder au données de mes layout je sais jamais trop ou mettre mon findViewById ... Du coup je reçois souvent l'erreur nullpointerexception, mais le truc ici c'est que j'ai mi un try catch, comme cela :
et très bizarrement, j'ai le dialogue de mon try qui s'affiche ainsi que celui de mon catch. Donc dans le try, il arrive bien à trouver la valeur, qu'il y a dans mon textview mDateDisplay et dans mon catch j'ai un nullpointerexcpetion sur ce meme textview mDateDisplay :S. Du coup je ne comprend pas trop où est l'erreur, je sais pas si quelqu'un saurait m aider ?? :s
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 private void updateDisplay() { mDateDisplay = (TextView) findViewById(R.id.dateDisplay); CharSequence mMonth2; try{ mMonth2 = mDateDisplay.getText(); Dialog d2 = new Dialog(NoteReminder.this); d2.setTitle(mMonth2); d2.show(); }catch(Exception e) { String error = e.toString(); Dialog d = new Dialog(NoteReminder.this); d.setTitle("Dang it!"); TextView tv = new TextView(NoteReminder.this); tv.setText(error); d.setContentView(tv); d.show(); } }
Merci
Partager