【问题标题】:Display details on list-view by comparing current time and database input time in java android通过比较java android中的当前时间和数据库输入时间来显示列表视图的详细信息
【发布时间】:2019-07-03 19:59:04
【问题描述】:

我正在开发一个显示公交车时刻表的应用程序。我使用firebase数据库,我将数据输入数据库并将其检索到我的应用程序上的列表视图。目前它显示了我输入到数据库的所有数据。我想通过比较当前时间和数据库上的输入时间来显示巴士详细信息,只有当时间值在范围内时。怎么做?有人请帮助我。

【问题讨论】:

    标签: java android firebase firebase-realtime-database android-listview


    【解决方案1】:
    ## Firebase ##
    when saving your data in firebase add your current timestamp in firebase
    
    ## App ##
    
    When retrieve from Firebase get your device current timestamp and compare with timestamp
    
    DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference();
    DatabaseReference eventsReference = databaseReference.child("bus");
    
    Query query = eventsReference.orderByChild("timestamp").startAt("device_current_timestamp");
    query.addValueEventListener(new ValueEventListener).....
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-06
      • 2016-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多