android - Empty Rows in listview -
whenever add new value in array creates 2 rows 1 empty row in listview. when delete value in array value removed both row still exists.
protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.listcontact); sharedpreferences=getsharedpreferences(preferences,context.mode_private); for(int i=1;i<=n+1;i++) { string st=sharedpreferences.getstring(string.valueof(i), ""); conact_list.add(st); } arrayadapter adapter=new arrayadapter<string>(getbasecontext(),android.r.layout.simple_list_item_1,conact_list); listview cv= (listview) findviewbyid(r.id.listview); cv.setadapter(adapter); }
i have checked arraylist , arrayadapter both doesnt have empty value or size in list view displays follow :
log:
04-25 12:40:31.491 30892-30892/com.symbols.syedibrahim.phonetrack d/err﹕ entered 04-25 12:40:31.501 30892-30892/com.symbols.syedibrahim.phonetrack d/err﹕ + 04-25 12:40:31.501 30892-30892/com.symbols.syedibrahim.phonetrack d/err﹕ +93838394 04-25 12:40:31.501 30892-30892/com.symbols.syedibrahim.phonetrack d/err﹕ +947574748 04-25 12:40:31.501 30892-30892/com.symbols.syedibrahim.phonetrack d/err﹕ +87478494 04-25 12:40:31.501 30892-30892/com.symbols.syedibrahim.phonetrack d/err﹕ aa created[93838394, 947574748, 87478494] 04-25 12:40:31.501 30892-30892/com.symbols.syedibrahim.phonetrack d/err﹕ lv3count3list view count:0 04-25 12:40:31.501 30892-30892/com.symbols.syedibrahim.phonetrack d/err﹕ la
below opinion:
case 1: check number of data object matching item in view. mean in for(int i=1;i<=n+1;i++
check value of n, equal number items displayed in view. if 2 values same, should check data in preference again.
otherwise, go case 2 : check adapter, in adapter should check getview
, getcount
method. number value returned getcount
must same number of data object.
Comments
Post a Comment