Java ViewPager-代码不为';我够不着适配器

Java ViewPager-代码不为';我够不着适配器,java,android,Java,Android,这是我的代码: ....... CollectionPagerAdapter mCollectionPagerAdapter; ViewPager mViewPager; @Override protected void onCreate(Bundle savedInstanceState) { Log.i("App", "U reaching Da onCreate"); super.onCreate(savedInstanceState); setConte

这是我的代码:

.......
CollectionPagerAdapter mCollectionPagerAdapter;
ViewPager mViewPager;

@Override
protected void onCreate(Bundle savedInstanceState) {  Log.i("App", "U reaching Da onCreate");       
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_fragment);


     mCollectionPagerAdapter =
                new CollectionPagerAdapter(
                        getSupportFragmentManager());
        mViewPager = (ViewPager) findViewById(R.id.CardsPager);
        mViewPager.setAdapter(mCollectionPagerAdapter);
  ....

    //ADAPTER:
class CollectionPagerAdapter extends FragmentStatePagerAdapter {
    public CollectionPagerAdapter(android.support.v4.app.FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int i) {
        Fragment fragment = new ObjectFragment();
        Bundle args = new Bundle();
        // Our object is just an integer :-P
        args.putInt(ObjectFragment.ARG_OBJECT, i + 1);
        fragment.setArguments(args);
        Log.i("App", "U reaching Da Adapter!!");
        return fragment;
    }

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

    @Override
    public CharSequence getPageTitle(int position) {
        return "OBJECT " + (position + 1);
    }
}
 .....
//ObjectFragment.java
public class ObjectFragment extends Fragment {
    public static final String ARG_OBJECT = "object";

    @Override
    public View onCreateView(LayoutInflater inflater,
        ViewGroup container, Bundle savedInstanceState) {
        // The last two arguments ensure LayoutParams are inflated
        // properly.
        View rootView = inflater.inflate(
            R.layout.cards_pager, container, false);
        Bundle args = getArguments();
        ((TextView) rootView.findViewById(android.R.id.text1)).setText(
            Integer.toString(args.getInt(ARG_OBJECT)));
        Log.i("App", "U reaching Da inflater Y U no work?!");
        return rootView;
    }
}
main_fragment.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="100" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:layout_weight="40"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:orientation="horizontal"
        android:background="#109922" >

    </LinearLayout>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:layout_weight="20"
    android:orientation="vertical" 
    android:background="#115599">

     <android.support.v4.view.ViewPager
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/CardsPager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#000000" >

     </android.support.v4.view.ViewPager>



</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:layout_weight="40"
    android:orientation="vertical" >



        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" 
            android:background="#ff9922">
        </LinearLayout>

</LinearLayout>

似乎应用程序从未到达适配器

我完全按照android开发者指南做的。 我不知道这里发生了什么,eclipse让我运行应用程序,代码中的每一项似乎都很好,但它就是不起作用,我终于做对了, 问题是我在onCreate()方法中设置了适配器,
为了解决这个问题,我在MainFragment中的onCreateView()方法中设置了适配器。

应用程序似乎从未到达适配器。-这是什么意思?您还可以发布布局文件
main_fragment.xml
?我在Adapter类中的logcat“Log.I”(“App”,“U reaching Da Adapter!!”)中发布了注释,但它没有出现在logcat中使用
0dp
作为设置了
权重的两个
线性布局的高度。其工作原理相同。。。你知道我能做些什么来解决我的问题吗?你能在ViewPager的顶部和底部看到不同颜色的线性布局吗?