必需的android.support.v4.app.Fragment,它已经存在

时间:2015-04-19 14:07:33

标签: java android android-fragments

我的导入已包含android.support.v4.app.Fragment,但它仍然显示此错误“找到:hind.jai.com.jaihind.PageFragment required android.support.v4.app.Fragment”。我正在学习本教程here

SampleFragmentPagerAdapter.java

package hind.jai.com.jaihind;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

/**
 * Created by Rishik on 19-04-2015.
 */
public class SampleFragmentPagerAdapter extends FragmentPagerAdapter {

    final int PAGE_COUNT = 3;
    private String tabTitles[] = new String[] { "Tab1", "Tab2", "Tab3" };

    public SampleFragmentPagerAdapter(FragmentManager fm) {
        super(fm);
    }

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

    @Override
    public Fragment getItem(int position) {
        return PageFragment.newInstance(position + 1); //error in PageFragment
    }

    @Override
    public CharSequence getPageTitle(int position) {
        // Generate title based on item position
        return tabTitles[position];
    }

}

0 个答案:

没有答案