我试图在RecyclerView中返回我的文档,尽管其中一个字段是键入timeStamp

时间:2018-08-26 10:51:55

标签: android android-recyclerview google-cloud-firestore

返回文档时,我的字段之一是TimeStamp,它似乎没有返回。在我的Session类中,get和set方法用于会话,我不确定设置startTime的类型,即日期或时间戳。

要弄清楚我要实现的目标:我的会话集合中的一个字段是时间戳类型,我想检索它并在recyclerview中显示它,我可以在普通视图中检索并显示此问题,但是我我需要在会话中进行交互,因此需要在recyclerview中进行检索。

这是我当前的代码。

public class MyRecyclerViewAdapter extends RecyclerView.Adapter<MyRecyclerViewHolder> {

DeleteSession deleteSession;
ArrayList<Session> sessionArrayList;

public MyRecyclerViewAdapter(DeleteSession deleteSession, ArrayList<Session> sessionArrayList) {
    this.deleteSession = deleteSession;
    this.sessionArrayList = sessionArrayList;
}

@NonNull
@Override
public MyRecyclerViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

    LayoutInflater layoutInflater = LayoutInflater.from(deleteSession.getBaseContext());
    View view = layoutInflater.inflate(R.layout.single_row, parent, false);

    return new MyRecyclerViewHolder(view);
}

@Override
public void onBindViewHolder(@NonNull MyRecyclerViewHolder holder, final int position) {

    holder.mModule.setText(sessionArrayList.get(position).getModule());
    holder.mTitle.setText(sessionArrayList.get(position).getTitle());
    holder.mDate.setText(sessionArrayList.get(position).getDate());
    holder.mRoom.setText(sessionArrayList.get(position).getRoom());
    //holder.mStartTime.setText(sessionArrayList.get(position).getStartTime()); THIS IS A TIMESTAMP IN FIRESTORE
    //
    holder.mDeleteSession.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            deleteSession(position);
        }
    });

}

private void deleteSession(int position) {

}

@Override
public int getItemCount() {
    return sessionArrayList.size();
}
}

0 个答案:

没有答案