Bonjour tout le monde.
Je reviens encore avec un autre problème, je suis entrain de travailler sur un projet Android (Projet academique). Je cherche à recuperer les donnes de ma DB et les afficher dans une ListView.
J'utilise le TabViewer créer par defaut par android pour faire les onglets donc avec les fragments
La bibliotheque ButterKnife pour recuperer mes vues
J'ai déclaré ma ListView dans le un fragment quand j'essaye alors de recuperer mes données, l'application plante et me renvoi les erreurs. Alors j'ai essayé de recuperer manuellement sans ButterKnife, j'ai la meme erreur, j'ai encore essayé de recuperer cette ListView directement la où j'appele le setter, toujours la meme chose.
Je suis sur cette erreur depuis 48 h vraiment j'ai besoin de l'aide à ce niveau
Quand j'utilise ButterKnife, j'ai l'erreur suivante :
Et quand j'essaye de recuperer mes Widget sans ButterKnife, j'obtiens ça :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 java.lang.IllegalStateException: Required view 'list_message' with ID 2131230836 for field 'listMessages' was not found. If this view is optional add '@Nullable' (fields) or '@Optional' (methods) annotation. at butterknife.internal.Utils.findRequiredView(Utils.java:92) at butterknife.internal.Utils.findRequiredViewAsType(Utils.java:104) at com.sombux.oumar.meeting.fragment.PlaceholderFragment_ViewBinding.<init>(PlaceholderFragment_ViewBinding.java:25) at java.lang.reflect.Constructor.newInstance0(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
voici la portion de code où il y' a problème :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setEmptyView(android.view.View)' on a null object reference at com.sombux.oumar.meeting.fragment.PlaceholderFragment.onCreateView(PlaceholderFragment.java:124) at android.support.v4.app.Fragment.performCreateView(Fragment.java:2346) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1428) at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1759)
et voici mon Fragment :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 listMessages = rootView.findViewById(R.id.list_message); emptyViewGroup = rootView.findViewById(R.id.empty_view_group); MessageDAO md = new MessageDAO(getActivity()); Cursor c = md.findAll(); listMessages.setEmptyView(emptyViewGroup); cursorAdapter = new MessageCursorAdapter(getActivity(), null); listMessages.setAdapter(cursorAdapter);
J'ai effectué des recherche mais toutes les solutions proposées non pas résolues ce problème.
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 <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/fragment_disc" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.sombux.oumar.meeting.fragment.PlaceholderFragment"> <ListView android:id="@+id/list_message" android:layout_width="match_parent" android:layout_height="match_parent" /> <TextView android:id="@+id/empty_title_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:layout_marginEnd="8dp" android:layout_marginStart="8dp" android:layout_marginTop="8dp" android:text="No Messages" android:textAppearance="?android:textAppearanceMedium" android:textStyle="bold" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <TextView android:id="@+id/empty_subtitle_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginEnd="8dp" android:layout_marginStart="8dp" android:text="Create a new contact by clicking the + button below" android:textAppearance="?android:textAppearanceSmall" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/empty_title_text" /> <android.support.constraint.Group android:id="@+id/empty_view_group" android:layout_width="wrap_content" android:layout_height="wrap_content" app:constraint_referenced_ids="empty_title_text,empty_subtitle_text" /> <include layout="@layout/bottom_main_content" /> </android.support.constraint.ConstraintLayout>
le problème est je ne peut recuperer aucun widget de mon fragment piusque j'ai essaye avec d'autres widget.
SVP aidez moi a resoudre ce probleme, je suis bloqué depuis 48 h.
Partager