IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Android Discussion :

Probleme De Recuperation De Donnees Firebase


Sujet :

Android

  1. #1
    Membre régulier Avatar de japhettchabao
    Homme Profil pro
    Développeur Java
    Inscrit en
    Septembre 2014
    Messages
    86
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : Togo

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2014
    Messages : 86
    Points : 75
    Points
    75
    Par défaut Probleme De Recuperation De Donnees Firebase
    Bonjour tout le monde, svp j'arrive a inserer des donnees dans firebase mais quand je tente de les afficher dans mon fragment liste_offres.xml, mon apli ne repond plus. voic le code d'affichage
    ListeOffres.java
    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
    package com.codeeaters.taffer;
     
    import android.os.Bundle;
    import android.support.annotation.NonNull;
    import android.support.v7.widget.LinearLayoutManager;
    import android.support.v7.widget.RecyclerView;
    import android.util.Log;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.ListView;
    import android.widget.TextView;
    import android.widget.Toast;
     
    import com.google.android.gms.common.ConnectionResult;
    import com.google.firebase.database.DatabaseReference;
    import com.google.firebase.database.FirebaseDatabase;
    import com.firebase.ui.database.FirebaseRecyclerAdapter;
     
    /**
     * Created by pondikpa on 12/01/17.
     */
     
    public class ListeOffres  extends android.support.v4.app.Fragment {
     
     
     
        public static class OffreViewHolder extends RecyclerView.ViewHolder{
            public TextView offreType;
            public TextView offreDomaine;
            public TextView offrePoste;
            public TextView offreEtude;
            public TextView offreContact;
            public TextView offreSalaire;
            public TextView offreAdresse;
            public TextView offreDescription;
     
            public OffreViewHolder(View v){
                super(v);
                offreType = (TextView)itemView.findViewById(R.id.typetxt);
                offreDomaine = (TextView)itemView.findViewById(R.id.domainetxt);
                offreEtude = (TextView)itemView.findViewById(R.id.scolairetxt);
                offrePoste = (TextView)itemView.findViewById(R.id.postetxt);
                offreContact = (TextView)itemView.findViewById(R.id.contacttxt);
                offreSalaire = (TextView)itemView.findViewById(R.id.salairetxt);
                offreAdresse = (TextView)itemView.findViewById(R.id.adressetxt);
                offreDescription = (TextView)itemView.findViewById(R.id.descriptiontxt);
     
            }
     
        }
        private static final String OFFRES = "offres";
        private static final String TAG = "ListeOffres";
        private  RecyclerView mOffreRecyclerView;
        private LinearLayoutManager mLinearLayoutManager;
        private DatabaseReference mFirebaseDatabaseReference;
        private  FirebaseRecyclerAdapter<OffresDAO, OffreViewHolder> mFirebaseAdapter;
     
     
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
            View rootView= inflater .inflate(R.layout.liste_offres, container, false);
            mOffreRecyclerView =(RecyclerView)rootView.findViewById(R.id.offreRecyclerView);
            Log.i(TAG, "onConnectionFailed: hein");
            mLinearLayoutManager = new LinearLayoutManager(this.getActivity());
            mLinearLayoutManager.setStackFromEnd(true);
            mFirebaseDatabaseReference = FirebaseDatabase.getInstance().getReference();
            mFirebaseAdapter = new FirebaseRecyclerAdapter<OffresDAO, OffreViewHolder>(
                OffresDAO.class,
                R.layout.offre,
                OffreViewHolder.class,
                mFirebaseDatabaseReference.child(OFFRES)){
                    @Override
                    protected void populateViewHolder(OffreViewHolder viewHolder, OffresDAO model, int position){
                        viewHolder.offreType.setText(model.getTypechoi());
                        viewHolder.offreDomaine.setText(model.getDomainechoi());
                        viewHolder.offreEtude.setText(model.getEtudechoi());
                        viewHolder.offrePoste.setText(model.getPostechoi());
                        viewHolder.offreSalaire.setText(model.getSalairechoi());
                        viewHolder.offreContact.setText(model.getContactchoi());
                        viewHolder.offreAdresse.setText(model.getAdressechoi());
                        viewHolder.offreDescription.setText(model.getDescriptionchoix());
                    }
     
                };
                mFirebaseAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver(){
                    @Override
                    public void onItemRangeInserted(int positionStart, int itemCount){
                        super.onItemRangeInserted(positionStart,itemCount);
                        int roomCount = mFirebaseAdapter.getItemCount();
                        int lastVisiblePosition = mLinearLayoutManager.findLastCompletelyVisibleItemPosition();
                        if (lastVisiblePosition == -1 || (positionStart >= (roomCount -1) && lastVisiblePosition == (positionStart -1))){
                            mOffreRecyclerView.scrollToPosition(positionStart);
                        }
                    }
                });
                mOffreRecyclerView.setLayoutManager(mLinearLayoutManager);
                mOffreRecyclerView.setAdapter(mFirebaseAdapter);
     
     
            return  rootView;
     
     
        }
        public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
            // An unresolvable error has occurred and Google APIs (including Sign-In) will not
            // be available.
            Log.d(TAG, "onConnectionFailed:" + connectionResult);
        }
    }
    voici le fragment liste_offres.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
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="com.codeeaters.taffer.MainActivity$PlaceholderFragment">
     
        <android.support.v7.widget.RecyclerView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:id="@+id/offreRecyclerView">
     
     
     
     
        </android.support.v7.widget.RecyclerView>
    </RelativeLayout>
    et le fichier Offres.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
    <?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="horizontal" android:layout_width="match_parent"
        android:layout_height="wrap_content">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <TextView
            android:text="Type"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/typetxt"
            android:textStyle="normal|bold"
            android:textColor="@color/colorPrimary" />
     
        <TextView
            android:text="Salaire"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/salairetxt" />
     
        <TextView
            android:text="Domaine"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/domainetxt" />
     
        <TextView
            android:text="Poste"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/postetxt" />
     
        <TextView
            android:text="Contact"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/contacttxt" />
     
        <TextView
            android:text="Scolaire"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/scolairetxt" />
     
        <TextView
            android:text="Adresse"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/adressetxt" />
     
        <TextView
            android:text="Description"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/descriptiontxt" />
    </LinearLayout>
    </ScrollView>
    le fichier DAO OffresDAO.java
    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
    package com.codeeaters.taffer;
     
    import java.util.Date;
     
    /**
     * Created by pondikpa on 11/01/17.
     */
     
    public class OffresDAO {
        public String postechoi,domainechoi,etudechoi,contactchoi,adressechoi,descriptionchoix,typechoi;
        private int offreid, salairechoi;
     
        public OffresDAO() {
        }
     
        public OffresDAO(String postechoi, String domainechoi, String etudechoi, String contactchoi, String adressechoi, String descriptionchoix, String typechoi, int offreid, int salairechoi) {
            this.postechoi = postechoi;
            this.domainechoi = domainechoi;
            this.etudechoi = etudechoi;
            this.contactchoi = contactchoi;
            this.adressechoi = adressechoi;
            this.descriptionchoix = descriptionchoix;
            this.typechoi = typechoi;
            this.offreid = offreid;
            this.salairechoi = salairechoi;
        }
     
        public int getOffreid() {
            return offreid;
        }
     
        public void setOffreid(int offreid) {
            this.offreid = offreid;
        }
     
        public String getPostechoi() {
            return postechoi;
        }
     
        public void setPostechoi(String postechoi) {
            this.postechoi = postechoi;
        }
     
        public String getDomainechoi() {
            return domainechoi;
        }
     
        public void setDomainechoi(String domainechoi) {
            this.domainechoi = domainechoi;
        }
     
        public String getEtudechoi() {
            return etudechoi;
        }
     
        public void setEtudechoi(String etudechoi) {
            this.etudechoi = etudechoi;
        }
     
        public String getContactchoi() {
            return contactchoi;
        }
     
        public void setContactchoi(String contactchoi) {
            this.contactchoi = contactchoi;
        }
     
        public String getAdressechoi() {
            return adressechoi;
        }
     
        public void setAdressechoi(String adressechoi) {
            this.adressechoi = adressechoi;
        }
     
        public String getDescriptionchoix() {
            return descriptionchoix;
        }
     
        public void setDescriptionchoix(String descriptionchoix) {
            this.descriptionchoix = descriptionchoix;
        }
     
        public String getTypechoi() {
            return typechoi;
        }
     
        public void setTypechoi(String typechoi) {
            this.typechoi = typechoi;
        }
     
        public int getSalairechoi() {
            return salairechoi;
        }
     
        public void setSalairechoi(int salairechoi) {
            this.salairechoi = salairechoi;
        }
    }
    Coordialement

  2. #2
    Membre actif Avatar de jmonga
    Homme Profil pro
    Développeur Java
    Inscrit en
    Novembre 2014
    Messages
    175
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 28
    Localisation : Congo-Kinshasa

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2014
    Messages : 175
    Points : 269
    Points
    269
    Par défaut
    Il se plante?

  3. #3
    Membre régulier Avatar de japhettchabao
    Homme Profil pro
    Développeur Java
    Inscrit en
    Septembre 2014
    Messages
    86
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : Togo

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2014
    Messages : 86
    Points : 75
    Points
    75
    Par défaut oui
    yep

  4. #4
    Membre actif Avatar de jmonga
    Homme Profil pro
    Développeur Java
    Inscrit en
    Novembre 2014
    Messages
    175
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 28
    Localisation : Congo-Kinshasa

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2014
    Messages : 175
    Points : 269
    Points
    269
    Par défaut
    Essai de regarder ton logcat.

  5. #5
    Membre régulier Avatar de japhettchabao
    Homme Profil pro
    Développeur Java
    Inscrit en
    Septembre 2014
    Messages
    86
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : Togo

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2014
    Messages : 86
    Points : 75
    Points
    75
    Par défaut le logcat
    01-30 08:16:25.735 30748-30748/com.codeeaters.taffer E/dalvikvm: Could not find class 'android.util.ArrayMap', referenced from method com.android.tools.fd.runtime.MonkeyPatcher.monkeyPatchExistingResources
    01-30 08:16:25.735 30748-30748/com.codeeaters.taffer E/dalvikvm: Could not find class 'android.util.ArrayMap', referenced from method com.android.tools.fd.runtime.MonkeyPatcher.pruneResourceCache
    01-30 08:16:25.825 30748-30748/com.codeeaters.taffer E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
    01-30 08:16:26.495 30748-30748/com.codeeaters.taffer E/RecyclerView: No adapter attached; skipping layout
    01-30 08:16:26.565 30748-30748/com.codeeaters.taffer E/RecyclerView: No adapter attached; skipping layout
    01-30 08:16:51.905 30748-30748/com.codeeaters.taffer E/AndroidRuntime: FATAL EXCEPTION: main
    android.content.res.Resources$NotFoundException: String resource ID #0x0
    at android.content.res.Resources.getText(Resources.java:254)
    at android.support.v7.widget.ResourcesWrapper.getText(ResourcesWrapper.java:52)
    at android.widget.TextView.setText(TextView.java:3875)
    at com.codeeaters.taffer.ListeOffres$1.populateViewHolder(ListeOffres.java:78)
    at com.codeeaters.taffer.ListeOffres$1.populateViewHolder(ListeOffres.java:71)
    at com.firebase.ui.database.FirebaseRecyclerAdapter.onBindViewHolder(FirebaseRecyclerAdapter.java:177)
    at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:5825)
    at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:5858)
    at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5094)
    at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4970)
    at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2029)
    at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1414)
    at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1377)
    at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:553)
    at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3315)
    at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3124)
    at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3568)
    at android.view.View.layout(View.java:14318)
    at android.view.ViewGroup.layout(ViewGroup.java:4573)
    at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1076)
    at android.view.View.layout(View.java:14318)
    at android.view.ViewGroup.layout(ViewGroup.java:4573)
    at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1767)
    at android.view.View.layout(View.java:14318)
    at android.view.ViewGroup.layout(ViewGroup.java:4573)
    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1687)
    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1541)
    at android.widget.LinearLayout.onLayout(LinearLayout.java:1450)
    at android.view.View.layout(View.java:14318)
    at android.view.ViewGroup.layout(ViewGroup.java:4573)
    at android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1139)
    at android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:833)
    at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:847)
    at android.view.View.layout(View.java:14318)
    at android.view.ViewGroup.layout(ViewGroup.java:4573)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
    at android.view.View.layout(View.java:14318)
    at android.view.ViewGroup.layout(ViewGroup.java:4573)
    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1687)
    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1541)
    at android.widget.LinearLayout.onLayout(LinearLayout.java:1450)
    at android.view.View.layout(View.java:14318)
    at android.view.ViewGroup.layout(ViewGroup.java:4573)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
    at android.view.View.layout(View.java:14318)
    at android.view.ViewGroup.layout(ViewGroup.java:4573)
    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1687)
    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1541)
    at android.widget.LinearLayout.onLayout(LinearLayout.java:1450)
    at android.view.View.layout(View.java:14318)
    at android.view.ViewGroup.layout(ViewGroup.java:4573)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
    at android.view.View.layout(View.java:14318)
    at android.view.ViewGroup.layout(ViewGroup.java:4573)
    at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2000)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1754)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1013)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5507)

  6. #6
    Modérateur
    Avatar de Hizin
    Homme Profil pro
    Développeur mobile
    Inscrit en
    Février 2010
    Messages
    2 180
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France

    Informations professionnelles :
    Activité : Développeur mobile

    Informations forums :
    Inscription : Février 2010
    Messages : 2 180
    Points : 5 072
    Points
    5 072
    Par défaut
    Le problème se situe au niveau de tes setText.
    Il faut bien que tu t'assures de passer soit une ID de String ressources, soit une String.
    Tu as un problème au moins sur viewHolder.offreSalaire.setText(model.getSalairechoi());. Ce morceau de code, au lieu de signifier "mon TextView a comme String le salaire" signifie "mon TextView doit afficher la ressource String ayant pour ID le salaire". Sur tes valeurs entières passées en paramètres à TextView#setText, assure-toi bien de les enrober de String#valueOf pour ne pas avoir ce problème.

  7. #7
    Membre régulier Avatar de japhettchabao
    Homme Profil pro
    Développeur Java
    Inscrit en
    Septembre 2014
    Messages
    86
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : Togo

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2014
    Messages : 86
    Points : 75
    Points
    75
    Par défaut exemple
    peux tu me donner un exemple stp? sa maiderait bcp

  8. #8
    Membre actif Avatar de jmonga
    Homme Profil pro
    Développeur Java
    Inscrit en
    Novembre 2014
    Messages
    175
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 28
    Localisation : Congo-Kinshasa

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2014
    Messages : 175
    Points : 269
    Points
    269
    Par défaut
    Code JAVA : Sélectionner tout - Visualiser dans une fenêtre à part
    viewHolder.offreSalaire.setText(String.valueof(model.getSalairechoi()));

Discussions similaires

  1. Réponses: 0
    Dernier message: 16/05/2008, 11h00
  2. Problème de récupération de données?
    Par bonsam dans le forum Dreamweaver
    Réponses: 6
    Dernier message: 17/10/2006, 14h42
  3. Réponses: 3
    Dernier message: 03/10/2006, 23h20
  4. [Struts] Probleme de recuperation de donnees
    Par DanZzz dans le forum Struts 1
    Réponses: 1
    Dernier message: 12/05/2006, 08h39
  5. [SGBD] probleme de recuperation de donnee d'une bdd Mysql
    Par chex dans le forum SQL Procédural
    Réponses: 8
    Dernier message: 13/04/2006, 17h05

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo