Вопрос

Data is not binding in array list as it came from the Service, as like first option which added in ArrayList is Lead, second is Qualified, and third is test. When i check list on first position it shows Qualified, Lead, test. But i want as i bind my list as it show in that sequence.

public static HashMap<String,ArrayList<LeadData>> LeadDataMap= new HashMap<String,ArrayList<LeadData>>();
public static ArrayList<String> aList = new ArrayList<String>();



for (int i = 0; i < LeadListsJSONArray.length(); i++) {
JSONObject Leadsobj = LeadListsJSONArray.getJSONObject(i);

//get stage name for hashmap key value..
String StageNameString = Leadsobj.getString("StageName");
String StageIdString = Leadsobj.getString("StageId");
System.out.println("stage id........................"+StageIdString);
//get new leads list..
JSONArray jaarr2 = new JSONArray(Leadsobj.getString("Leads"));
ArrayList<LeadData> leadDataList = new ArrayList<LeadData>();

for (int j = 0; j < jaarr2.length(); j++) {
    LeadData ld = new LeadData();

    JSONObject obj3 = jaarr2.getJSONObject(j);

    ld.setLeadCompanyName(obj3.getString("LeadCompanyName"));
    ld.setLeadId(obj3.getString("LeadId"));
    ld.setTitle(obj3.getString("Title"));

    leadDataList.add(ld);
}
//here we are puttin the leaddatalist inot map with respect to stage name...
LeadDataMap.put(StageNameString.trim().toString(), leadDataList);
//LeadDataMap.put(StageIdString, leadDataList);

}

In LeadDataMap data in not in that sequence in that i have put. This is the problem.

Это было полезно?

Решение

I get solution by using LinkedHashmap.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top