gpt4 book ai didi

android - 2.3 崩溃应用程序中的 fragment

转载 作者:行者123 更新时间:2023-11-29 13:58:18 24 4
gpt4 key购买 nike

我正在尝试使用 android.support v4 jar 在 2.2/2.3 android 项目中实现 fragment ,但它一直崩溃并给我这个错误:

06-07 14:23:43.774: E/AndroidRuntime(3085): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{mike.android.ie/mike.android.ie.ActivityView}: java.lang.ClassNotFoundException: mike.android.ie.ActivityView in loader dalvik.system.PathClassLoader[/data/app/mike.android.ie-1.apk]

我在代码中还有其他 fragment ,但已将其注释掉以尝试让一个 fragment 正常工作,如果您能帮助我,我将不胜感激。

我正在使用的类是:

ActivityView.java

package mike.android.ie;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

public class ActivityView extends FragmentActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}

ma​​in.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">

<RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content">

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:name="mike.android.ie.ImageViewFragment" android:layout_width="200dip"
android:layout_height="wrap_content" android:id="@+id/image_fragment"
android:layout_alignParentTop="true"

/>

</RelativeLayout>

然后我有一个ImageViewFragment.java:

package mike.android.ie;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

public class ImageViewFragment extends Fragment {

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {

ImageView image = (ImageView) inflater.inflate(R.layout.imagefragment, container, false);

return image;

}

}

imagefragment.xml:

<?xml version="1.0" encoding="utf-8"?>

<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/img"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/myimage01" />

list .xml

<?xml version="1.0" encoding="utf-8"?>

<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET"/>

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".ActivityView"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name=".ImageViewFragment" android:screenOrientation="landscape"
android:configChanges="orientation" />
<activity android:name=".TickerFragment" android:screenOrientation="landscape"
android:configChanges="orientation" />
<activity android:name=".WebViewFragment" android:screenOrientation="landscape"
android:configChanges="orientation" />
<activity android:name=".VideoViewFragment" android:screenOrientation="landscape"
android:configChanges="orientation" />
</application>

最佳答案

错误:mike.android.ie/mike.android.ie.ActivityView 看起来不像标准 fragment compa 库。您包含的任何其他库是否会导致此错误?

关于android - 2.3 崩溃应用程序中的 fragment ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10933140/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com