对于我的项目,我的所有java类都在一个包中 - com.example.android.bitmapfun
- 我的清单是:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.bitmapfun"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:description="@string/app_description"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name="com.example.android.bitmapfun.ImageGridActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.android.bitmapfun.ImageDetailActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.FullScreen" >
</activity>
</application>
</manifest>
和活动是:
package com.example.android.bitmapfun;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
public class ImageGridActivity extends FragmentActivity {
private static final String TAG = "ImageGridFragment";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getSupportFragmentManager().findFragmentByTag(TAG) == null) {
final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.add(android.R.id.content, new ImageGridFragment(), TAG);
ft.commit();
}
}
}
ImageDeatilActivity.java:
package com.example.android.bitmapfun;
import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.DisplayMetrics;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.WindowManager.LayoutParams;
import android.widget.Toast;
import com.example.android.bitmapfun.R;
import com.example.android.bitmapfun.Images;
import com.example.android.bitmapfun.DiskLruCache;
import com.example.android.bitmapfun.ImageCache;
import com.example.android.bitmapfun.ImageFetcher;
import com.example.android.bitmapfun.ImageResizer;
import com.example.android.bitmapfun.ImageWorker;
import com.example.android.bitmapfun.Utils;
public class ImageDetailActivity extends FragmentActivity implements OnClickListener {
private static final String IMAGE_CACHE_DIR = "images";
public static final String EXTRA_IMAGE = "extra_image";
private ImagePagerAdapter mAdapter;
private ImageResizer mImageWorker;
private ViewPager mPager;
@SuppressLint("NewApi")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.image_detail_pager);
.....
}
LogCat:here
为什么LogCat会在这里显示ClassNotFoundException?我试过但无法清除错误。请任何想法来克服这个问题。
答案 0 :(得分:1)
要使用此FragMentActivity
类,您的应用程序必须在其清单中指定“11”或更高级别的API级别,并针对支持相同或更高API级别的Android库版本进行编译。
答案 1 :(得分:0)
对于它的价值,当我将BitmapFun项目导入Eclipse时,我无法获得任何解决方案。这是因为ClassNotFoundException。我注意到该项目缺少libs文件夹和支持库,但是创建libs文件夹并将支持库放入其中并没有解决问题。因此,我在Eclipse中创建了一个新项目,从原始导入的项目中传输了文件,并且它在第一次尝试时起作用。胜利。