android - Custom BaseAdapter or CursorAdapter or CursorLoader? -
android - Custom BaseAdapter or CursorAdapter or CursorLoader? -
i have 2 fragment:
fragment a: here user enters info , stored in database. fragment b: here entered info loaded database in listview in onresume lifecycle method.
now, problem having every time info added , fragment b opened, entire listview
reloaded. want load row added listview
. using custom baseapadter
. no cursoradapter
or cursorloader
!
to avoid don't utilize setadapter() everytime info changes. i.e:
create method refresh info in adapter
class sampleadapter extends baseadapter { public void refreshdata(string[] arraydata) { this.arraydata = arraydata; notifydatasetchanged(); } }
check if adapter set in activity
if (listview.getadapter() == null) { adapter = new sampleadapter(getactivity(), data); listview.setadapter(adapter); } else adapter.refreshdata(data);
android
Comments
Post a Comment