0

Here is my code where I am getting the data from "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)

  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

  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.

shuabing
  • 679
  • 11
  • 28
Abhi
  • 385
  • 1
  • 4
  • 13

1 Answers1

-1

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. 3) If you want to display 10 and 1 separately then you need 2 characters.

Liam
  • 27,717
  • 28
  • 128
  • 190
Pavya
  • 6,015
  • 4
  • 29
  • 42
  • return filter.get(position).get("name").toString().toUpperCase()subSequence(0, 1).charAt(0); – Abhi Jan 13 '17 at 09:54