android - When I scroll of the custom listview in fragment, it's content doesn't seem -


i have custom listview in tabhost in fragment. when scroll custom listview, textview contents destroy, seem empty. here codes

public class myfragment extends fragment { private tabhost tabhost; private view view; private arraylist<string> list = new arraylist<string>(); private arraylist<string> listmydataids = new arraylist<string>(); private listview lstviewmydata; private sql sql; private mydataadapter adpmydata; private int = 0;  @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {     view = inflater.inflate(r.layout.activity_content, container, false);     initialize();     sql = new sql(view.getcontext());     sql.opentoread();     listmydataids = sql.get(list);     sql.close();     adpmydata = new mydataadapter(view.getcontext());     return view; }  @override public void onactivitycreated(bundle savedinstancestate) {     super.onactivitycreated(savedinstancestate);     sql = new sql(view.getcontext());     sql.opentoread();      listmydataids = sql.get(list);     string[] stockarr = new string[listmydataids.size()];     stockarr = listmydataids.toarray(stockarr);     lstviewmydata.setadapter(adpmydata);      sql.close(); }  public class mydataadapter extends arrayadapter<string> {     private context c;     private sql sql;     public mydataadapter(context context) {         super(context, r.layout.mydata_listview_row, list);         this.c = context;     }     @override     public view getview(int position, view convertview, viewgroup parent) {         final layoutinflater inflater = layoutinflater.from(c);         view v = inflater.inflate(r.layout.mydata_listview_row, parent, false);         textview txt1 = (textview) v.findviewbyid(r.id.txt1);         textview txt2 = (textview) v.findviewbyid(r.id.txt2);         textview txt3 = (textview) v.findviewbyid(r.id.txt3);         sql = new sql(c);         sql.opentoread();         listmydataids = sql.get(list);         if (i < listmydataids.size()){             txt1.settext((sql.get(list);             txt2.settext((sql.get(list));             txt3.settext((sql.get(list);             i++;         }         sql.close();         return v;     } }  private void initialize() {     tabhost=(tabhost) view.findviewbyid(r.id.tabhost);     tabhost.setup();     tabspec spec1=tabhost.newtabspec("tab 1");     spec1.setcontent(r.id.tab1);     tabspec spec2=tabhost.newtabspec("tab 2");     spec2.setcontent(r.id.tab2);     tabspec spec3=tabhost.newtabspec("tab 3");     spec3.setcontent(r.id.tab3);     tabhost.addtab(spec1);     tabhost.addtab(spec2);     tabhost.addtab(spec3);     // tabhost.setcurrenttab(0);     lstviewmydata = (listview) view.findviewbyid(r.id.lstmydata); } 

enter image description here enter image description here enter image description here

how can fix situation ?


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -