【问题标题】:sorting in real time firebase console panel实时排序firebase控制台面板
【发布时间】:2020-11-23 04:53:17
【问题描述】:

我想对这些数据进行排序,以 JSON 格式显示 这是我将自己的数据上传到实时数据库时的代码

还有一个我要整理的图片结果

  HashMap<String, Object> map = new HashMap<>();
        map.put("1_UserName", a_name);
        map.put("2_phonenumber", phonenumber);
        map.put("3_Date", currentDate);
        map.put("4_Time", currentTime);
        map.put("5_Door_acess", check_Door_acess);
        map.put("6_StructuralCabling", check_StructuralCabling);
        map.put("7_Lightening", check_Lightening);
        map.put("8_check_FireSystem", check_FireSystem);
        map.put("9_AirConditioning", check_AirConditioning);
        map.put("10_Rack_01_Network", stringcheck_Rack_01_Network);
        map.put("11_PowerSourceLine1R_01", PowerSourceLine1R01);
        map.put("12_PowerSourceLine2_R01", PowerSourceLineR01);
        map.put("13_EarthingR01", EarthingR01);
        map.put("14_ofPDUsR01", ofPDUsR01editText_String11);
        map.put("15_ofOutlets_PDUR01", ofOutlets_PDUR01editText_String11);
        map.put("16_Horizontal_VerticalR01", Horizontal_VerticalR01);
        map.put("17_PPOSWOPPR01", PPOSWOPPR01);
        

        FirebaseDatabase.getInstance().getReference().child("ammar").setValue(map);

这张图片来自 consol

【问题讨论】:

    标签: android firebase firebase-realtime-database firebase-console


    【解决方案1】:

    Firebase 控制台正在按预期对子键进行排序。它们按字符串值排序lexicographically,或字典顺序。它不会使用您放在每个孩子开头的数值。

    如果你需要它们按字符串前缀进行数字排序,你应该用 0 填充数字值,这样数字的宽度都是相同的:

            map.put("01_UserName", a_name);
            map.put("02_phonenumber", phonenumber);
            map.put("03_Date", currentDate);
            map.put("04_Time", currentTime);
            map.put("05_Door_acess", check_Door_acess);
            map.put("06_StructuralCabling", check_StructuralCabling);
            map.put("07_Lightening", check_Lightening);
            map.put("08_check_FireSystem", check_FireSystem);
            map.put("09_AirConditioning", check_AirConditioning);
            map.put("10_Rack_01_Network", stringcheck_Rack_01_Network);
            map.put("11_PowerSourceLine1R_01", PowerSourceLine1R01);
            map.put("12_PowerSourceLine2_R01", PowerSourceLineR01);
            map.put("13_EarthingR01", EarthingR01);
            map.put("14_ofPDUsR01", ofPDUsR01editText_String11);
            map.put("15_ofOutlets_PDUR01", ofOutlets_PDUR01editText_String11);
            map.put("16_Horizontal_VerticalR01", Horizontal_VerticalR01);
            map.put("17_PPOSWOPPR01", PPOSWOPPR01);
    

    如果您期望更大的数字,请使用更多的 0。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-23
      • 2022-01-24
      • 2019-04-21
      • 1970-01-01
      • 1970-01-01
      • 2018-10-23
      • 2016-02-11
      • 1970-01-01
      相关资源
      最近更新 更多