samedi 7 mars 2015

android listview adapter combine two arrays

I'm wornig sqllite.i have some tables and i select name for example Customer Table and Price from AnotherTable. and i received two array list .first name's array list and secods price's array list. this is a my source



private ArrayList<GetDictioanyClassByPosition> GetPKFromTable() {
price_array.clear();
ArrayList<GetDictioanyClassByPosition> my_list = d_Helper
.getAllPriceByPosition(0);
for (int i = 0; i < my_list.size(); i++) {
String AllPrice = my_list.get(i).getDictionaryPrice();
GetDictioanyClassByPosition cnt = new GetDictioanyClassByPosition();
System.err.println(AllPrice + "AllPrice");
cnt.setDictionaryPrice(AllPrice);
price_array.add(cnt);
}
return price_array;
}


this is a method to check price's array list and this method check name's array list



public void AllInfoFromLoanAnalysis() {

name_list.clear();

ArrayList<GetAllDictionariesClass> contact_array_from_db = d_Helper
.getAllInformationFromLoanAnalysis_Table(1, 1);

Log.e("Sizee", contact_array_from_db.size() + "sizee");
for (int i = 0; i < contact_array_from_db.size(); i++) {
int DictionaryID = contact_array_from_db.get(i).getDictionaryID();

System.out.println(DictionaryID + "DictionaryID");

GetDictioanyClassByPosition object = new GetDictioanyClassByPosition();
String name = null ;

ArrayList<GetDictioanyClassByPosition> DictionaryIdList = d_Helper
.GetDictionaryIdList(DictionaryID);

System.out.println(DictionaryIdList.size() + "DictionaryIdList");
Log.e("Sizee2", DictionaryIdList.size() + "sizee2");

for (int j = 0; j < DictionaryIdList.size(); j++) {
name= DictionaryIdList.get(j).getDictionaryName();


Log.e("object", name + "object");
object.setDictionaryName(name);


name_list.add(object);
}

for (int j = 0; j < price_array.size(); j++) {

String AllPrice = price_array.get(i).getDictionaryPrice();
object.setDictionaryPrice(AllPrice);
object.setDictionaryName(name);
price_array.add(object);
}
agroproductslistview.setAdapter(agroproduct_adapter);

}
}


and i called my BaseAdapter Like this



_adapter = new LoanProductAdapter(
getApplicationContext(), R.layout.productlistadapter,
name_list);


i can selected and show my prices and names in different array list but i want to marge both array list and would adapter in my list view .how i can solve my problem? if anyone knows solution please help me thanks


Aucun commentaire:

Enregistrer un commentaire