0

我有以下代码...

import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
...
public class LevelSelectorFragmentActivity extends FragmentActivity {
  ...
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_level);
    this.mAdapter = new LevelFragmentPagerAdapter(this);
  }
  private static class LevelFragmentPagerAdapter extends FragmentPagerAdapter {

    public LevelFragmentPagerAdapter(FragmentActivity a) {
        super(a.getSupportFragmentManager());
    }

    @Override
    public Fragment getItem(int position) {
        return Level1Fragment.newInstance();
    }

    @Override
    public int getCount() {
        return NUMBER_OF_PAGES;
    }

  }
}

这工作正常,但是当我将表单 FragmentActivity 更改为 Activity 并将导入更改如下...

导入 org.gleason.superhockey.fragment.Level1Fragment;

import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.support.v13.app.FragmentPagerAdapter;
public class LevelSelectorFragmentActivity extends Activity {

private static final int NUMBER_OF_PAGES = 2;
private LevelFragmentPagerAdapter mAdapter;

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_level);
    this.mAdapter = new LevelFragmentPagerAdapter(this);
}

private static class LevelFragmentPagerAdapter extends FragmentPagerAdapter {

    public LevelFragmentPagerAdapter(Activity a) {
        super(a.getFragmentManager());
    }

    @Override
    public Fragment getItem(int position) {
        return Level1Fragment.newInstance();
    }

    @Override
    public int getCount() {
        return NUMBER_OF_PAGES;
    }

}

}

我得到以下 ClassNotFound ...

java.lang.NoClassDefFoundError: org.gleason.superhockey.LevelSelectorFragmentActivity$LevelFragmentPagerAdapter

例如,我正在使用这个

谁能看到我错过了什么?

4

1 回答 1

-1

It's possible that your library .jar is in the wrong directory or is added twice to the project. Make sure your support library .jar is in /libs folder. Then check Build Path and remove the support library from it (if it's there). Clean project.

于 2013-03-01T16:43:48.127 回答