我正在尝试按照开发人员指南here在android中实现可跳过的选项卡视图,但我收到编译错误,拒绝我的自定义TabListener:
[javac] /home/brad/Other/code/Prayson/Prayson/src/net/bradmont/prayson/Main.java:73: error: Main.HomeTabListener is not abstract and does not override abstract method onTabReselected(Tab,FragmentTransaction) in TabListener
[javac] private class HomeTabListener implements ActionBar.TabListener {
但是,我我重写onTabReselected,这是类定义:
private class HomeTabListener implements ActionBar.TabListener {
public void onTabReselected (ActionBar.Tab tab, FragmentTransaction ft) {
return; // I added this thinking a non-empty function would do something
}
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
mPager.setCurrentItem(tab.getPosition());
}
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
}
}
我试过复制&从API文档中粘贴函数定义,我尝试使用内联定义(new ActionBar.TabListener {..)。我确信这必须是简单的,但我没有线索。
有什么想法吗?谢谢!
答案 0 :(得分:0)
正如@Tanis.7x建议的那样,我正在混合来自support.v4的FragmentTransaction和来自native的ActionBar.Tab。切换到android.app.FragmentTransaction修复了问题。