我遇到了fragmentstatepageradapter
无法解决的错误。我导入了以下内容:
import android.support.v4.app.FragmentManager;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
我也尝试过:
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentStatePagerAdapter;
这是我的完整代码:
import android.support.v4.app.FragmentManager;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
public class FragmentPageAdapter extends FragmentPagerAdapter {
public FragmentPageAdapter(FragmentManager fm) {
super(fm);
// TODO Auto-generated constructor stub
}
@Override
public Fragment getItem(int arg0) {
// TODO Auto-generated method stub
switch (arg0) {
case 0:
return new JavaFragment();
case 1:
return new PhpFragment();
case 2:
return new DotnetFragment();
default:
break;
}
return null;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return 3;
}
}
这是y graddle.build代码:
申请插件:' com.android.application'
android { compileSdkVersion 22 buildToolsVersion" 22.0.1"
defaultConfig {
applicationId "aappen.com.buddiesnew"
minSdkVersion 21
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
incremental true
}
}
依赖项{
compile 'com.android.support:design:22.2.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile files('libs/mysql-connector-java-5.0.8-bin.jar')
compile files('libs/ePOS-Print.jar')
compile files('libs/printer-lib.jar')
compile files('libs/bsh-core-2.0b4.jar')
compile files('libs/velocity-1.5.jar')
compile files('libs/gcm-server.jar')
compile files('libs/annotations.jar')
compile files('libs/google-play-services.jar')
compile files('libs/gcm.jar')
}
答案 0 :(得分:2)
您对app.FragmentPagerAdapter
和support.v4.app.FragmentPagerAdapter
清除Android.app.Fragment
和
仅使用
import android.support.v4.app.FragmentPagerAdapter;
答案 1 :(得分:0)
在app gradle文件的依赖项中添加以下内容。
compile 'com.android.support:support-v13:22.2.0'
只需确保版本号与其他支持库的版本号相同。