java.lang.NoSuchMethodError: android.app.FragmentTransaction.attach compatibility library v13 issue -
i implementing actionbar swipe feature on tabs first time. running on honeycomb os (api level 11). hence have use support compatibility library v13 use view pager , other components used build swipe mechanism fragmentpageradapter.
i using tutorial on developer.android build this. here link.
however getting strange issue of no such method found attach , detach.
let me post full track trace
09-04 13:07:42.560: e/androidruntime(774): java.lang.nosuchmethoderror: android.app.fragmenttransaction.attach 09-04 13:07:42.560: e/androidruntime(774): @ android.support.v13.app.fragmentpageradapter.instantiateitem(fragmentpageradapter.java:99) 09-04 13:07:42.560: e/androidruntime(774): @ android.support.v4.view.viewpager.addnewitem(viewpager.java:832) 09-04 13:07:42.560: e/androidruntime(774): @ android.support.v4.view.viewpager.populate(viewpager.java:1016) 09-04 13:07:42.560: e/androidruntime(774): @ android.support.v4.view.viewpager.populate(viewpager.java:914) 09-04 13:07:42.560: e/androidruntime(774): @ android.support.v4.view.viewpager$3.run(viewpager.java:244) 09-04 13:07:42.560: e/androidruntime(774): @ android.os.handler.handlecallback(handler.java:587) 09-04 13:07:42.560: e/androidruntime(774): @ android.os.handler.dispatchmessage(handler.java:92) 09-04 13:07:42.560: e/androidruntime(774): @ android.os.looper.loop(looper.java:126) 09-04 13:07:42.560: e/androidruntime(774): @ android.app.activitythread.main(activitythread.java:3997) 09-04 13:07:42.560: e/androidruntime(774): @ java.lang.reflect.method.invokenative(native method) 09-04 13:07:42.560: e/androidruntime(774): @ java.lang.reflect.method.invoke(method.java:491) 09-04 13:07:42.560: e/androidruntime(774): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:841) 09-04 13:07:42.560: e/androidruntime(774): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:599) 09-04 13:07:42.560: e/androidruntime(774): @ dalvik.system.nativestart.main(native method)
i have gone through same link represent same issue didnt solve problem. this link same issue
i not using actionbarsherloc running on api level 11.
i posting adapter class , tablistener in case want give look.
public class mypageradapter extends fragmentpageradapter{ fragment mfragment; public mypageradapter(fragmentmanager fm) { super(fm); // todo auto-generated constructor stub } @override public android.app.fragment getitem(int position) { // todo auto-generated method stub switch (position) { case 0: mfragment = (patientforms)new patientforms(); return mfragment; case 1: mfragment = (vitals)new vitals(); return mfragment; case 2: mfragment = (chartsactivity)new chartsactivity(); return mfragment; case 3: mfragment = (note)new note(); return mfragment; default: return null; } } @override public int getcount() { // todo auto-generated method stub return 4; } @override public void destroyitem(viewgroup container, int position, object object) { // todo auto-generated method stub } } private class mytablistener implements actionbar.tablistener { private fragment mfragment; private final activity mactivity; private final string mfragname; public mytablistener( activity activity, string fragname ) { mactivity = activity; mfragname = fragname; } @override public void ontabselected( tab tab, fragmenttransaction ft ) { log.i(tag, "tab position set "+tab.getposition()); pager.setcurrentitem(tab.getposition()); } @override public void ontabreselected(tab tab, android.app.fragmenttransaction ft) { // todo auto-generated method stub } @override public void ontabunselected(tab tab, android.app.fragmenttransaction ft) { // todo auto-generated method stub // ft.remove( mfragment ); // mfragment = null; } }
try this
public android.support.v4.app.fragment getitem(int position) { // todo auto-generated method stub switch (position) { default: return null; } }
update
check import statements , replace lines
import android.app.fragment; import android.app.fragmentmanager; import android.app.fragmenttransaction; import android.app.fragmentactivity;
replace this
import android.support.v4.app.fragmentactivity; import android.support.v4.app.fragment; import android.support.v4.app.fragmentmanager; import android.support.v4.app.fragmenttransaction;
Comments
Post a Comment