FragmentPagerAdapter

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

public class MyPageAdapter extends FragmentPagerAdapter {

String[] types=new String[]{
        "http://ic.snssdk.com/2/article/v25/stream/?count=20&min_behot_time=1465264149&bd_latitude=4.9E-324&bd_longitude=4.9E-324&bd_loc_time=1465265107&loc_mode=5&lac=4527&cid=28883&iid=4464422609&device_id=17258390367&ac=wifi&channel=baidu&aid=13&app_name=news_article&version_code=460&device_platform=android&device_type=SAMSUNG&os_api=19&os_version=4.4.4&uuid=353040417908000&openudid=84c1c7b192991cc6"
        ,"http://ic.snssdk.com/2/article/v25/stream/?category=news_hot&count=20&min_behot_time=1465198210&bd_latitude=4.9E-324&bd_longitude=4.9E-324&bd_loc_time=1465265107&loc_mode=5&lac=4527&cid=28883&iid=4464422609&device_id=17258390367&ac=wifi&channel=baidu&aid=13&app_name=news_article&version_code=460&device_platform=android&device_type=SAMSUNG&os_api=19&os_version=4.4.4&uuid=353040417908000&openudid=84c1c7b192991cc6"
        ,"http://ic.snssdk.com/2/article/v25/stream/?category=video&count=20&min_behot_time=1465197958&bd_latitude=4.9E-324&bd_longitude=4.9E-324&bd_loc_time=1465265107&loc_mode=5&lac=4527&cid=28883&iid=4464422609&device_id=17258390367&ac=wifi&channel=baidu&aid=13&app_name=news_article&version_code=460&device_platform=android&device_type=SAMSUNG&os_api=19&os_version=4.4.4&uuid=353040417908000&openudid=84c1c7b192991cc6"
        ,"http://ic.snssdk.com/2/article/v25/stream/?category=news_society&count=20&min_behot_time=1465198214&bd_latitude=4.9E-324&bd_longitude=4.9E-324&bd_loc_time=1465265107&loc_mode=5&lac=4527&cid=28883&iid=4464422609&device_id=17258390367&ac=wifi&channel=baidu&aid=13&app_name=news_article&version_code=460&device_platform=android&device_type=SAMSUNG&os_api=19&os_version=4.4.4&uuid=353040417908000&openudid=84c1c7b192991cc6"
        ,"http://ic.snssdk.com/2/article/v25/stream/?category=news_entertainment&count=20&min_behot_time=1465266126&bd_latitude=4.9E-324&bd_longitude=4.9E-324&bd_loc_time=1465265107&loc_mode=5&lac=4527&cid=28883&iid=4464422609&device_id=17258390367&ac=wifi&channel=baidu&aid=13&app_name=news_article&version_code=460&device_platform=android&device_type=SAMSUNG&os_api=19&os_version=4.4.4&uuid=353040417908000&openudid=84c1c7b192991cc6"
        ,"http://ic.snssdk.com/2/article/v25/stream/?category=news_tech&count=20&min_behot_time=1465266200&bd_latitude=4.9E-324&bd_longitude=4.9E-324&bd_loc_time=1465265107&loc_mode=5&lac=4527&cid=28883&iid=4464422609&device_id=17258390367&ac=wifi&channel=baidu&aid=13&app_name=news_article&version_code=460&device_platform=android&device_type=SAMSUNG&os_api=19&os_version=4.4.4&uuid=353040417908000&openudid=84c1c7b192991cc6"
        ,"http://ic.snssdk.com/2/article/v25/stream/?category=news_car&count=20&bd_latitude=4.9E-324&bd_longitude=4.9E-324&bd_loc_time=1465265107&loc_mode=5&lac=4527&cid=28883&iid=4464422609&device_id=17258390367&ac=wifi&channel=baidu&aid=13&app_name=news_article&version_code=460&device_platform=android&device_type=SAMSUNG&os_api=19&os_version=4.4.4&uuid=353040417908000&openudid=84c1c7b192991cc6"
        ,"http://ic.snssdk.com/2/article/v25/stream/?category=image_ppmm&count=20&min_behot_time=1465266950&bd_latitude=4.9E-324&bd_longitude=4.9E-324&bd_loc_time=1465265107&loc_mode=5&lac=4527&cid=28883&iid=4464422609&device_id=17258390367&ac=wifi&channel=baidu&aid=13&app_name=news_article&version_code=460&device_platform=android&device_type=SAMSUNG&os_api=19&os_version=4.4.4&uuid=353040417908000&openudid=84c1c7b192991cc6"
        ,"http://ic.snssdk.com/2/article/v25/stream/?category=news_sports&count=20&min_behot_time=1465266305&bd_latitude=4.9E-324&bd_longitude=4.9E-324&bd_loc_time=1465265107&loc_mode=5&lac=4527&cid=28883&iid=4464422609&device_id=17258390367&ac=wifi&channel=baidu&aid=13&app_name=news_article&version_code=460&device_platform=android&device_type=SAMSUNG&os_api=19&os_version=4.4.4&uuid=353040417908000&openudid=84c1c7b192991cc6"

};
        FragmentManager fm;
        String[]  ss;
        private Fragment1 f1;
        public MyPageAdapter(FragmentManager fm,String[] ss) {
            super(fm);
            // TODO Auto-generated constructor stub
            this.fm=fm;
            this.ss=ss;
        }
        @Override
        public Fragment getItem(int arg0) {
            // TODO Auto-generated method stub

             f1=new Fragment1();
            Bundle bundle=new Bundle();
            bundle.putString("type",types[arg0]);
            f1.setArguments(bundle);


        return f1;
        }
        @Override
        public int getCount() {
            // TODO Auto-generated method stub
            return ss.length;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            // TODO Auto-generated method stub
            return ss[position];
        }

}

你可能感兴趣的:(FragmentPagerAdapter)