如下面的代码所示,使用mFragList.add
时,方法add
会被红色波浪标记。为什么虽然我有另一个项目使用相同的方法添加fragments
,但eclipse识别它?
*注意:*
当鼠标悬停在红色波浪上时,日食说
The method add(Fragment) in the type List<Fragment> is not applicable for the arguments (Fragment02)
。所有`Fragment01(),Fragment02(),Fragment03()扩展片段
Java_Code:
import java.util.ArrayList;
import java.util.List;
import com.example.viewpagerwithactiontabstest00.adapter.MyTabsPagerAdapter;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
public class MainActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
List<Fragment> mFragList = new ArrayList<Fragment>();
mFragList.add(new Fragment01());
mFragList.add(new Fragment02());
mFragList.add(new Fragment03());
ViewPager mViewPager = (ViewPager) findViewById(R.id.pager);
MyTabsPagerAdapter mPagerAdapter = new MyTabsPagerAdapter(getSupportFragmentManager());
}
}