我的应用程序有一个操作栏和片段。我将 tablistener 用于操作栏的选项卡:
package com.infomercados.appinfomercados;
import android.app.ActionBar;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.app.ActionBar.Tab;
import android.util.Log;
public class TabListener implements ActionBar.TabListener {
private Fragment fragment;
public TabListener(Fragment fg)
{
this.fragment = fg;
}
@Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
Log.i("ActionBar", tab.getText() + " reselected.");
}
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
Log.i("ActionBar", tab.getText() + " selected.");
ft.replace(R.id.container, fragment);
}
@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
Log.i("ActionBar", tab.getText() + " no selected.");
ft.remove(fragment);
}
}
我想适应早期版本,我添加了 android-support-v6-appcompat.jar 但产生了这个错误: Class requires API level 11 (current min is 7): android.app.ActionBar.TabListener
你能帮助我吗?
很感谢。