嗨,我正在进行查询,我能够查询值并将它们放入列表。这是我的代码:
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);
}
}
});
}
全局变量
ParseObject enviaMensaje;
ParseObject recibeMensaje;
String objectIdRecibeMensaje;
String objectIdEnviaMensaje;
在onCreateView中
objectIdRecibeMensaje=recibeMensaje.getObjectId();
objectIdEnviaMensaje=enviaMensaje.getObjectId();
当我运行应用程序时,它一直说是空的!我需要将parseObject作为String返回,以便我可以看到这些值是否包含在arraylist中。
if(listaDeChats.contains(objectIdRecibeMensaje)&& listaDeChats.contains(enviaMensaje)){
}
onCreateView
仅用于创建视图本身,而不是其他任何东西。
如果你想处理片段中的子视图(我假设你正在使用它),你必须在onViewCreated
方法中处理它们。