我使用SherlockFragmentActivity,我有:
public class TestActivity extends SherlockFragmentActivity {
private static enum Tab {
Test1("test1", TestOneFragment.class),
Test2("test2", TestTwoFragment.class),
private final String title;
private final Class<? extends Fragment> clazz;
private Tab(String title, Class<? extends Fragment> clazz) {
this.title = title;
this.clazz = clazz;
}
private String getTitle() {
return title;
}
private Class<? extends Fragment> getFragmentClass() {
return clazz;
}
}
它工作正常,因为我在相同的“包”中有Test1和Test2。
如何添加外部“包”类?当我导入com.bla.blaa.BlaActivity; 我这样用:
private static enum Tab {
Blabla("Blabla", BlaActivity.class),
Test1("test1", TestOneFragment.class),
Test2("test2", TestTwoFragment.class);
我有错误:
The constructor TestActivity.Tab(String, Class<BlaActivity>) is
undefined
答案 0 :(得分:0)
您无法传递给不扩展片段的SherlockFragmentActivity构造函数类。您似乎正在尝试将活动(BlaActivity.class)传递给Tab。 SherlockFragmentActivity与片段一起使用。您可以使用意图从其中一个选项卡启动其他应用程序:
Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.package.address");
startActivity(launchIntent);