完整代码为here,以下是我的代码,在调用library(data.table)
setDT(df)[2:3, names := 'elisa']
df
# names
#1: george
#2: elisa
#3: elisa
#4: tony
时,它始终会引发new PagerAdapter(fragmentManager)
Container.groovy
Could not find matching constructor for: ro.vst.Container$PagerAdapter(ro.vst.Container, android.app.FragmentManagerImpl)
错误:
void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState)
setContentView(R.layout.container)
ViewPager pager = (ViewPager) findViewById(R.id.pager)
PagerAdapter pagerAdapter = new PagerAdapter(fragmentManager)
pager.setAdapter(pagerAdapter)
}
class PagerAdapter extends FragmentPagerAdapter {
PagerAdapter(FragmentManager fm) {
super(fm)
}
@Override
Fragment getItem(int position) {
return new Slider();
}
@Override
int getCount() {
return 2
}
}
更新
即使我将代码更改为 Caused by: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: ro.vst.Container$PagerAdapter(ro.vst.Container, android.app.FragmentManagerImpl)
at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1723)
at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1526)
at org.codehaus.groovy.runtime.callsite.MetaClassConstructorSite.callConstructor(MetaClassConstructorSite.java:46)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:232)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:252)
at ro.vst.Container.onCreate(Container.groovy:19)
at android.app.Activity.performCreate(Activity.java:5933)
,错误仍然存在
答案 0 :(得分:1)
您的fragmentManager不匹配。片段管理器应该是相同的,android.app ....或android.support.v4 .....
所以在你的代码中请尝试
pager.setAdapter(new MyAdapter(getFragmentManager()));
getFragmentManager()位于android.support.v4.app.Fragment
下并在你的适配器
public MyAdapter(FragmentManager fm) {
super(fm);
}
这里'FragmentManager fm'在android.support.v4.app.FragmentManager下;