У меня есть много старых приложений на основе активности в Play Store.Уже два дня я пытаюсь сделать первые шаги с помощью фрагментов.Я до сих пор не понимаю.Я прочитал в основном все документы, блоги и руководства по фрагментам, но мое глупое простое тестовое приложение отказывается начинать с ClassNotFoundException для MyActivity.
Итак, вот что я сделал до сих пор:
НачалоFragmentActivity под названием MyActivity:
public class MyActivity extends FragmentActivity {
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.myactivity);
}
}
Вот макет / myactivity.xml:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<fragment
class="com.test.app.Table1List"
android:id="@+id/table1list"
android:layout_height="match_parent"
android:layout_width="match_parent" />
</LinearLayout>
Это ListFragment с его XML-файлом:
public class Table1List extends ListFragment {
@Override
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
if (viewGroup == null) {
return null;
}
return layoutInflater.inflate(R.layout.table1list, viewGroup);
}
}
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ListView
android:drawSelectorOnTop="false"
android:fastScrollEnabled="true"
android:id="@id/android:list"
android:layout_height="fill_parent"
android:layout_width="fill_parent" />
<TextView
style="@style/TextViewMedium"
android:id="@id/android:empty"
android:text="@string/txt_noresult" />
</LinearLayout>
Позвоните мнеглупо, но я всегда получаю исключение ActivityNotFoundException во время запуска FragmentActivity MyActivity.
Любая помощь очень ценится.
EDIT :
Я взялпоследний Пакет Совместимости v4 от нескольких дней назад.Я выпускал чистые проекты почти каждые 10 минут - без дела.
Вот Манифест:
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0"
package="com.test.app" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="11" />
<application
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher"
android:label="@string/txt_appname" >
<activity
android:label="@string/txt_appname"
android:name="MyActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
РЕДАКТИРОВАТЬ 2 : Вот LogCat:
Unable to resolve superclass of Lcom/test/app/MyActivity; (25)
Link of class 'Lcom/test/app/MyActivity;' failed
Shutting down VM
threadid=3: thread exiting with uncaught exception (group=0x4001b188)
Uncaught handler: thread main exiting due to uncaught exception
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.test.app/com.test.app.MyActivity}: java.lang.ClassNotFoundException: com.test.app.MyActivity in loader dalvik.system.PathClassLoader@44bfda38
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
at android.app.ActivityThread.access$2200(ActivityThread.java:119)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4363)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.test.app.MyActivity in loader dalvik.system.PathClassLoader@44bfda38
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409)
... 11 more
РЕДАКТИРОВАТЬ 3 : Я переустановил пакет поддержки, создал новый проект с пакетом совместимости v4, разобрал все до MyActivity и одного фрагмента -> та же ошибка.Я даже тестировал предыдущий пакет Support v4 (выпуск 6).
Это мои первые шаги с Fragments после почти трех лет разработки под Android (множество приложений на рынке).Кажется, что все это сломано.
Это дерево проекта в затмении - любая помощь по-прежнему крайне необходима.
![enter image description here](https://i.stack.imgur.com/fxE8K.png)