【发布时间】:2013-08-31 18:29:06
【问题描述】:
我在使用 AndroidAnnotations 实现 SherlockFragmentActivity 时遇到了麻烦。 我正在使用AndroidKickstartR bootstrap 项目。
当我开始活动时,我收到一个错误:
java.lang.ClassNotFoundException: pl.itify.fichas.app.set.FichasSetsNewFragment_
在提取片段之前,应用程序运行良好,所以我认为问题不在于 AndroidAnnotations 配置。
我已经尝试将 SherlockFragment 更改为 Fragment 或 v4.Fragment 并且错误是相同的。
我使用 Maven 构建应用程序。我检查了目标文件夹, pl.itify.fichas.app.set.FichasSetsNewFragment_ 类已正确生成并且也包含在 .jar 文件中。
我有三个班级:
FichasSetsActivity:
@EActivity(R.layout.fichas_sets_activity)
@OptionsMenu(R.menu.fichas_sets_activity)
public class FichasSetsActivity extends SherlockFragmentActivity
{
@FragmentById(R.id.fichas_set_list_new_fragment)
FichasSetsNewFragment fichasSetsNewFragment;
@FragmentById(R.id.fichas_set_list_list_fragment)
FichasSetsListFragment fichasSetsListFragment;
}
FichasSetsNewFragment:
@EFragment(R.layout.fichas_sets_new_fragment)
public class FichasSetsNewFragment extends SherlockFragment {
}
FichasSetsListFragment:
@EFragment(R.layout.fichas_sets_list_fragment)
public class FichasSetsListFragment extends SherlockFragment {
}
fichas_sets_activity.xml 布局文件如下所示:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/fichas_set_list_new_fragment"
android:name="pl.itify.fichas.app.set.FichasSetsNewFragment_"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<fragment
android:id="@+id/fichas_set_list_list_fragment"
android:name="pl.itify.fichas.app.set.FichasSetsListFragment_"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
任何提示都将不胜感激,因为我已经被这个问题困扰了几个小时了:(
干杯!
【问题讨论】:
-
您确定 pl.itify.fichas.app.set.FichasSetsNewFragment_ 应该有下划线吗?
-
我也有疑问,尝试删除下划线,但最终我发现它明确指出here需要下划线。
-
你应该在AndroidKickstartR上打开一个关于这个的问题。
-
既然您已经找到了解决方案,您应该将其发布为答案并将其标记为已接受。
标签: android android-fragments actionbarsherlock android-annotations