简体   繁体   English

[Android]在Stickyheaderlistview中排序时出现问题

[英][Android]Issue in sorting in Stickyheaderlistview

Here is my code where I am getting the data from "tbl_customer". 这是我从“ tbl_customer”获取数据的代码。

qry = " select DISTINCT [name],cast([value] AS TEXT) AS [value] from [tbl_Customers] where 1=1 "
        .concat(" AND [name] IN")
        .concat("(")
        .concat("'DIS_FIELD_COLLECTION_EXECUTIVE','FIELD_EXECUTIVE_NAME'")
        .concat(") ")
        //.concat(" AND [value] != '' AND [value] IS NOT NULL ")
        .concat(" ORDER BY [value]; ");
Log.i("empname", qry);
cur1 = db.rawQuery(qry, null);
Log.i("empname", "" + cur1.getCount());
int _empcount = 0;
HashMap<String, String> map = new HashMap<String, String>();
HashMap<List<String>, List<String>> map1 = new HashMap<List<String>, List<String>>();
List<String> _empid = new ArrayList<String>();

while (cur1.moveToNext()) {

if (cur1.getString(cur1.getColumnIndex("name")).equalsIgnoreCase("DIS_FIELD_COLLECTION_EXECUTIVE")) {

    map.put("id", cur1.getString(cur1.getColumnIndex("value")));
    Log.e("empcount1", cur1.getString(cur1.getColumnIndex("value")));
    employee_local_id.add(cur1.getString(cur1.getColumnIndex("value")));


} else if (cur1.getString(cur1.getColumnIndex("name")).equalsIgnoreCase("FIELD_EXECUTIVE_NAME")) {

    map.put("name", cur1.getString(cur1.getColumnIndex("value")).toUpperCase());

    Log.e("empcount2", cur1.getString(cur1.getColumnIndex("value")));

    emp.add(map);

    adp_emp = new Listadapter_emp(emp, Tracker_filter_Activity.this);
    lst_employee.setAdapter(adp_emp);

    map = new HashMap<String, String>();


}

Here I am getting output like on Stickyheaderlistview like(posted in log) 在这里,我得到的输出就像在Stickyheaderlistview上一样(张贴在日志中)

  01-13 14:02:22.653 12822-12822/com.wp.focus E/empcount1: 1
  01-13 14:02:22.654 12822-12822/com.wp.focus E/empcount1: 10
  01-13 14:02:22.654 12822-12822/com.wp.focus E/empcount1: 11
  01-13 14:02:22.656 12822-12822/com.wp.focus E/empcount1: 2
  01-13 14:02:22.656 12822-12822/com.wp.focus E/empcount1: 3
  01-13 14:02:22.657 12822-12822/com.wp.focus E/empcount1: 4
  01-13 14:02:22.657 12822-12822/com.wp.focus E/empcount1: 5
  01-13 14:02:22.658 12822-12822/com.wp.focus E/empcount1: 6
  01-13 14:02:22.658 12822-12822/com.wp.focus E/empcount1: 8
  01-13 14:02:22.658 12822-12822/com.wp.focus E/empcount1: 9
  01-13 14:02:22.659 12822-12822/com.wp.focus E/empcount2: AZAD NAGAR-TAN001    
  01-13 14:02:22.660 12822-12822/com.wp.focus E/empcount2: AZADALAM NAGAR-TAN002    
  01-13 14:02:22.661 12822-12822/com.wp.focus E/empcount2: KARAN SHAH-TKS001    
  01-13 14:02:22.662 12822-12822/com.wp.focus E/empcount2: KISHAN PATEL-TKP001    
  01-13 14:02:22.662 12822-12822/com.wp.focus E/empcount2: PRRADDSFSF PPPRSDFSDF-TPP002    
  01-13 14:02:22.664 12822-12822/com.wp.focus E/empcount2: PURVANG PANDYA-FPP022
  01-13 14:02:22.665 12822-12822/com.wp.focus E/empcount2: SDSDHH XDGHGSDFHGSD-TSX001    
  01-13 14:02:22.667 12822-12822/com.wp.focus E/empcount2: TEST TEST-TTT002    
  01-13 14:02:22.667 12822-12822/com.wp.focus E/empcount2: hythy asxas-Tha001    
  01-13 14:02:22.668 12822-12822/com.wp.focus E/empcount2: twestt tesst-Ttt001 

Main Issue is there are 2 t's ie(TEST TEST-TTT002 and twestt tesst-Ttt001) Issue is I am getting Both differently,both name should come under T but output is like 主要问题是有2 t,即(TEST TEST-TTT002和twestt tesst-Ttt001)问题是我得到的意思是两者都不同,两者都应放在T之下,但输出就像

  T
  TEST TEST-TTT002
  S
  SDSDHH XDGHGSDFHGSD-TSX001
  t
  twestt tesst-Ttt001

@Override
    public long getHeaderId(int position) {
        //return the first character of the country as ID because this is what headers are based upon
        return filter.get(position).get("name").toString().subSequence(0, 1).charAt(0);
    }

Thank you in advance for solving. 预先感谢您的解决。

1) Make sure your array list is sorted 2) Check in getHeaderId T and t return value- if its returning different value then convert to upper case or lower case. 1)确保数组列表已排序2)检入getHeaderId T和t返回值-如果返回不同的值,则转换为大写或小写。 3) If you want to display 10 and 1 separately then you need 2 characters. 3)如果要分别显示10和1,则需要2个字符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM