0

这是我从“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>();


}

在这里,我得到了像 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 

主要问题是有 2 个 t 即(TEST TEST-TTT002 和 twestt 测试-Ttt001

  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);
    }

提前感谢您的解决。

4

1 回答 1

-1

1)确保您的数组列表已排序 2)检查 getHeaderId T 和 t 返回值 - 如果它返回不同的值,则转换为大写或小写。3) 如果要分别显示 10 和 1,则需要 2 个字符。

于 2017-01-13T09:47:03.713 回答