android - how to resolve UnsupportedOperationException Required method destroyItem was not overridden -
though have override destroyitem(...)
in pageradapter
getting error while sliding pages in viewpager
unsupportedoperationexception required method destroyitem not overridden
java code
public class propertypageradapter extends pageradapter { private context _context; private int layoutid; private list<addpropertyinfo> datalist; public propertypageradapter(context context, int resourceid, list<addpropertyinfo> objects) { // todo auto-generated constructor stub _context = context; layoutid = resourceid; datalist = objects; } @override public int getcount() { // todo auto-generated method stub homecoming datalist.size(); } @override public boolean isviewfromobject(view v, object obj) { // todo auto-generated method stub homecoming v == ((view) obj); } @override public void destroyitem(viewgroup container, int position, object object) { // todo auto-generated method stub super.destroyitem(container, position, object); ((viewpager) container).removeview((view) object); } @suppresslint("defaultlocale") @override public object instantiateitem(viewgroup container, int position) { // todo auto-generated method stub layoutinflater inflater = (layoutinflater) _context.getsystemservice( context.layout_inflater_service); view pagerview = inflater.inflate(layoutid, container, false); textview propertynametxtview = (textview) pagerview. findviewbyid(r.id.propertynametxtview); textview netincometxtview = (textview) pagerview. findviewbyid(r.id.netincometxtview); textview netincomevaluetxtview = (textview) pagerview. findviewbyid(r.id.netincomevaluetxtview); textview netexptxtview = (textview) pagerview. findviewbyid(r.id.netexptxtview); textview netexpvaluetxtview = (textview) pagerview. findviewbyid(r.id.netexpvaluetxtview); textview netprofittxtview = (textview) pagerview. findviewbyid(r.id.netprofittxtview); textview netprofitvaluetxtview = (textview) pagerview. findviewbyid(r.id.netprofitvaluetxtview); propertynametxtview.settypeface(utils.getregulartypeface(_context)); netincometxtview.settypeface(utils.getregulartypeface(_context)); netincomevaluetxtview.settypeface(utils.getregulartypeface(_context)); netexptxtview.settypeface(utils.getregulartypeface(_context)); netexpvaluetxtview.settypeface(utils.getregulartypeface(_context)); netprofittxtview.settypeface(utils.getregulartypeface(_context)); netprofitvaluetxtview.settypeface(utils.getregulartypeface(_context)); string propertyname = ""; double netincomeval; double netexpval; double netprofitval; addpropertyinfo addpropertyinfo = datalist.get(position); netincomeval = addpropertyinfo.getincomeamnt(); netexpval = addpropertyinfo.getexpamnt(); netprofitval = netincomeval - netexpval; propertyname = addpropertyinfo.getpropertyname(); string netincomevalstr = string.format("%.2f", netincomeval); string netexpvalstr = string.format("%.2f", netexpval); string netprofitvalstr = string.format("%.2f", netprofitval); propertynametxtview.settext(propertyname); netincomevaluetxtview.settext(_context.getresources(). getstring(r.string.doller) + netincomevalstr); netexpvaluetxtview.settext(_context.getresources(). getstring(r.string.doller) + netexpvalstr); netprofitvaluetxtview.settext(_context.getresources(). getstring(r.string.doller) + netprofitvalstr); ((viewpager) container).addview(pagerview); homecoming pagerview; } }
error log
10-30 18:59:11.711: e/androidruntime(27093): fatal exception: main 10-30 18:59:11.711: e/androidruntime(27093): process: com.teklabs.portfoliomanagenent, pid: 27093 10-30 18:59:11.711: e/androidruntime(27093): java.lang.unsupportedoperationexception: required method destroyitem not overridden 10-30 18:59:11.711: e/androidruntime(27093): @ android.support.v4.view.pageradapter.destroyitem(pageradapter.java:192) 10-30 18:59:11.711: e/androidruntime(27093): @ android.support.v4.view.pageradapter.destroyitem(pageradapter.java:124) 10-30 18:59:11.711: e/androidruntime(27093): @ com.teklabs.portfoliomanagenent.adapter.propertypageradapter.destroyitem(propertypageradapter.java:47) 10-30 18:59:11.711: e/androidruntime(27093): @ android.support.v4.view.viewpager.populate(viewpager.java:1002) 10-30 18:59:11.711: e/androidruntime(27093): @ android.support.v4.view.viewpager.populate(viewpager.java:914) 10-30 18:59:11.711: e/androidruntime(27093): @ android.support.v4.view.viewpager$3.run(viewpager.java:244) 10-30 18:59:11.711: e/androidruntime(27093): @ android.view.choreographer$callbackrecord.run(choreographer.java:803) 10-30 18:59:11.711: e/androidruntime(27093): @ android.view.choreographer.docallbacks(choreographer.java:603) 10-30 18:59:11.711: e/androidruntime(27093): @ android.view.choreographer.doframe(choreographer.java:572) 10-30 18:59:11.711: e/androidruntime(27093): @ android.view.choreographer$framedisplayeventreceiver.run(choreographer.java:789) 10-30 18:59:11.711: e/androidruntime(27093): @ android.os.handler.handlecallback(handler.java:733) 10-30 18:59:11.711: e/androidruntime(27093): @ android.os.handler.dispatchmessage(handler.java:95) 10-30 18:59:11.711: e/androidruntime(27093): @ android.os.looper.loop(looper.java:157) 10-30 18:59:11.711: e/androidruntime(27093): @ android.app.activitythread.main(activitythread.java:5356) 10-30 18:59:11.711: e/androidruntime(27093): @ java.lang.reflect.method.invokenative(native method) 10-30 18:59:11.711: e/androidruntime(27093): @ java.lang.reflect.method.invoke(method.java:515) 10-30 18:59:11.711: e/androidruntime(27093): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1265) 10-30 18:59:11.711: e/androidruntime(27093): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:1081) 10-30 18:59:11.711: e/androidruntime(27093): @ dalvik.system.nativestart.main(native method)
how resolve it?
don't phone call super. remove
super.destroyitem(container, position, object);
an extract of pageradapter source code
123 public void more ...destroyitem(viewgroup container, int position, object object) { 124 destroyitem((view) container, position, object); 125 } 191 public void more ...destroyitem(view container, int position, object object) { 192 throw new unsupportedoperationexception("required method destroyitem not overridden"); 193 }
android android-viewpager
No comments:
Post a Comment