java - Data from list of objects of model class is not retrieving correctly? -


when try retrieve single object listconcard (in activity class contactcard.class), "conname" contactcards receives correctly not getting correct data sibling arrays "conphonetype", "conphonevalue", "conemailtype", "conemailvalue".

listconcard list of objects of model class contactcardmodel.class.

i adding "contactcardmodel" objects in listconcard follows

listconcard.add(new contactcardmodel(conname, conphonetype, conphonevalue, conemailtype, conemailvalue));  

and retrieving data of "contactcardmodel" objects follows

for(int = 0; < listconcard.size(); i++){      log.e("inadp", listconcard.get(i).getconname()); // name returing correctly.      for(int x = 0; x < listconcard.get(i).getconphonetype().size(); x++)         log.e("inadp conphone", listconcard.get(i).getconphonetype().get(x) + ": " + listconcard.get(i).getconphonevalue().get(x));        for(int x = 0; x < listconcard.get(i).getconemailtype().size(); x++)         log.e("inadp conemail", listconcard.get(i).getconemailtype().get(x) + ": " + listconcard.get(i).getconemailvalue().get(x));  } 

values of both arrays getconphonetype , getconphonevalue returning 0 elements

values of both arrays getconemailtype , getconemailvalueare returning 1 element

size of conphonetype , conphonevalue same

size of conemailtype , conemailvalue same

contactcard.class

string conname; list<string> conphonetype; list<string> conphonevalue; list<string> conemailtype; list<string> conemailvalue; list<contactcardmodel> listconcard;  int = 1;      (addressbookcontact addressbookcontact : list) {          conname = addressbookcontact.name;          conphonetype.clear();         conphonevalue.clear();         if(addressbookcontact.phones != null) {              (int x = 0; x < addressbookcontact.phones.size(); x++) {                 int type = (int) addressbookcontact.phones.keyat(x);                 string typename = (string) contactscontract.commondatakinds.phone.gettypelabel(addressbookcontact.res, type, "");                 string phvalue = addressbookcontact.phones.valueat(x);                  conphonetype.add(typename);                 conphonevalue.add(phvalue);             }         }          conemailtype.clear();         conemailvalue.clear();         if(addressbookcontact.emails != null){              for(int x = 0; x < addressbookcontact.emails.size(); x++){                 int type = (int) addressbookcontact.emails.keyat(x);                 string typename = (string) contactscontract.commondatakinds.phone.gettypelabel(addressbookcontact.res, type, "");                 string emailvalue = addressbookcontact.emails.valueat(x);                  conemailtype.add(typename);                 conemailvalue.add(emailvalue);             }         }          listconcard.add(new contactcardmodel(conname, conphonetype, conphonevalue, conemailtype, conemailvalue));      } 

contactcardmodel.class

public class contactcardmodel {  string conname; list<string> conphonetype; list<string> conphonevalue; list<string> conemailtype; list<string> conemailvalue;  public contactcardmodel(string mconname, list<string> mconphonetype, list<string> mconphonevalue,                         list<string> mconemailtype, list<string> mconemailvalue){      conphonetype = new arraylist<string>();     conphonevalue = new arraylist<string>();     conemailtype = new arraylist<string>();     conemailvalue = new arraylist<string>();      this.conname = mconname;     this.conphonetype = mconphonetype;     this.conphonevalue = mconphonevalue;     this.conemailtype = mconemailtype;     this.conemailvalue = mconemailvalue; }  public string getconname() {     /*log.e("inadp conname", this.conname);*/     return conname; }  public void setconname(string conname) {     this.conname = conname; }  public list<string> getconphonetype() {     /*for(int = 0; < this.conphonetype.size(); i++){         log.e("inadp conphone", this.conphonetype.get(i)*//* + ": " + this.conphonevalue.get(i)*//*);     }*/     return conphonetype; }  public void setconphonetype(list<string> conphonetype) {     this.conphonetype = conphonetype; }  public list<string> getconphonevalue() {     return conphonevalue; }  public void setconphonevalue(list<string> conphonevalue) {     this.conphonevalue = conphonevalue; }  public list<string> getconemailtype() {     /*for(int = 0; < this.conemailtype.size(); i++){         log.e("inadp conemail", this.conemailtype.get(i)*//* + ": " + this.conemailvalue.get(i)*//*);     }*/     return conemailtype; }  public void setconemailtype(list<string> conemailtype) {     this.conemailtype = conemailtype; }  public list<string> getconemailvalue() {     return conemailvalue; }  public void setconemailvalue(list<string> conemailvalue) {     this.conemailvalue = conemailvalue; }   } 

try below modification. unable run , test code code provided not enough compile , run. in contactcard.java

string conname; list<string> conphonetype; list<string> conphonevalue; list<string> conemailtype; list<string> conemailvalue; list<contactcardmodel> listconcard = new arraylist<contactcardmodel>();  int = 1;      (addressbookcontact addressbookcontact : list) {          conname = addressbookcontact.name;          conphonetype = new arraylist<string>();         conphonevalue = new arraylist<string>();         if(addressbookcontact.phones != null) {              (int x = 0; x < addressbookcontact.phones.size(); x++) {                 int type = (int) addressbookcontact.phones.keyat(x);                 string typename = (string) contactscontract.commondatakinds.phone.gettypelabel(addressbookcontact.res, type, "");                 string phvalue = addressbookcontact.phones.valueat(x);                  conphonetype.add(typename);                 conphonevalue.add(phvalue);             }         }          conemailtype = new arraylist<string>();         conemailvalue = new arraylist<string>();         if(addressbookcontact.emails != null){              for(int x = 0; x < addressbookcontact.emails.size(); x++){                 int type = (int) addressbookcontact.emails.keyat(x);                 string typename = (string) contactscontract.commondatakinds.phone.gettypelabel(addressbookcontact.res, type, "");                 string emailvalue = addressbookcontact.emails.valueat(x);                  conemailtype.add(typename);                 conemailvalue.add(emailvalue);             }         }          listconcard.add(new contactcardmodel(conname, conphonetype, conphonevalue, conemailtype, conemailvalue));      } 

in constructor of contactcardmodel.java

public contactcardmodel(string mconname, list<string> mconphonetype, list<string> mconphonevalue,                     list<string> mconemailtype, list<string> mconemailvalue){  this.conname = mconname; this.conphonetype = mconphonetype; this.conphonevalue = mconphonevalue; this.conemailtype = mconemailtype; this.conemailvalue = mconemailvalue; 

}


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -