我正在尝试创建一个由tablayout组成的片段,所以我使用的是FragmentTabHost,但是代码中的setup()方法给出了如下错误 -
public class PayFrag extends Fragment {
private FragmentTabHost mTabHost ;
View mRoot;
TabHost tabHost;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mTabHost = new FragmentTabHost(getActivity());
mTabHost.setup(getActivity(),getChildFragmentManager(),R.layout.payfrag);
代码中的lastline会出现错误
我甚至更新了gradle中的android.support-v4 - 这是我的模块gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
defaultConfig {
applicationId "com.example.sairav.app3"
minSdkVersion 17
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:support-v4:22.1.1'
}