0

Hi i am doing a query and i was able to query the value and put them into a list.here is my code:

private void queryChatClass(){
    ParseQuery<ParseObject> query=ParseQuery.getQuery("Chat");
    //query.whereEqualTo("EnviaMensaje",ParseUser.getCurrentUser().getObjectId());
    query.include("EnviaMensaje");
    query.include("RecibeMensaje");
    query.orderByDescending("createdAt");
    query.findInBackground(new FindCallback<ParseObject>() {
        @Override
        public void done(List<ParseObject> objects, ParseException e) {
            for (ParseObject obj : objects) {
                enviaMensaje = obj.getParseObject("EnviaMensaje");
                objectIdEnviaMensaje=enviaMensaje.getObjectId();
                Log.i("AVE","Este es el id del que envia el mensaje"+enviaMensaje);

                recibeMensaje= obj.getParseObject("RecibeMensaje");
                objectIdRecibeMensaje=recibeMensaje.getObjectId();
                Log.i("AVE","Este es el id del que recibe el mensaje"+recibeMensaje);

                //Date hora=obj.ge
                // tDate("createdAt");
                idChat=obj.getObjectId();
                String mensaje= (String) obj.get("NombreRecibeMensaje");
                Log.i("AVE","mensaje"+mensaje);


                listaDeChats.add(obj);
            }
        }
    });
}

the global variables

ParseObject enviaMensaje;
ParseObject recibeMensaje;

String objectIdRecibeMensaje;
String objectIdEnviaMensaje;

in the onCreateView

objectIdRecibeMensaje=recibeMensaje.getObjectId();
objectIdEnviaMensaje=enviaMensaje.getObjectId();

When i run the app it keeps saying is null! i need the return of the parseObject as a String so i can see if this values are contained in the arraylist.

 if(listaDeChats.contains(objectIdRecibeMensaje)&& listaDeChats.contains(enviaMensaje)){

            }
Felipe Franco
  • 171
  • 3
  • 15

1 Answers1

0

onCreateView is only intended for creating the view itself, nothing else.

If you want to handle the child views in your fragment (which I assume you're using) you must handle them in the onViewCreated method.

92AlanC
  • 1,327
  • 2
  • 14
  • 33