第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

FragmentPagerAdapter

FragmentPagerAdapter

慕粉4089507 2017-06-12 12:22:26
求幫忙看下程序錯(cuò)在哪,謝謝activity_main<?xml?version="1.0"?encoding="utf-8"?> <RelativeLayout ????xmlns:android="http://schemas.android.com/apk/res/android" ????android:layout_width="match_parent" ????android:layout_height="match_parent"> ????????<android.support.v4.view.ViewPager ????????????android:id="@+id/view_pager" ????????????android:layout_width="match_parent" ????????????android:layout_height="match_parent"> ????????</android.support.v4.view.ViewPager> </RelativeLayout>layout01<?xml?version="1.0"?encoding="utf-8"?> <LinearLayout?xmlns:android="http://schemas.android.com/apk/res/android" ??????????????xmlns:app="http://schemas.android.com/apk/res-auto" ??????????????android:orientation="vertical" ??????????????android:layout_width="match_parent" ??????????????android:layout_height="match_parent"> ????<ImageView ????????android:id="@+id/image_view01" ????????android:layout_width="match_parent" ????????android:layout_height="match_parent" ????????android:src="@drawable/a"/> </LinearLayout>layout02<?xml?version="1.0"?encoding="utf-8"?> <LinearLayout?xmlns:android="http://schemas.android.com/apk/res/android" ??????????????xmlns:app="http://schemas.android.com/apk/res-auto" ??????????????android:orientation="vertical" ??????????????android:layout_width="match_parent" ??????????????android:layout_height="match_parent"> ????<ImageView ????????android:id="@+id/image_view02" ????????android:layout_width="match_parent" ????????android:layout_height="match_parent" ????????android:src="@drawable/b"/> </LinearLayout>layout03<?xml?version="1.0"?encoding="utf-8"?> <LinearLayout?xmlns:android="http://schemas.android.com/apk/res/android" ??????????????xmlns:app="http://schemas.android.com/apk/res-auto" ??????????????android:orientation="vertical" ??????????????android:layout_width="match_parent" ??????????????android:layout_height="match_parent"> ????<ImageView ????????android:id="@+id/image_view03" ????????android:layout_width="match_parent" ????????android:layout_height="match_parent" ????????android:src="@drawable/c"/> </LinearLayout>Fragment01public?class?Fragment01?extends?Fragment?{ ????@Nullable ????@Override ????public?View?onCreateView(LayoutInflater?inflater,?@Nullable?ViewGroup?container,?@Nullable?Bundle?savedInstanceState)?{ ????????View?view1=inflater.inflate(R.layout.layout01,container,false); ????????return?view1; ????} }Fragment02public?class?Fragment02?extends?Fragment?{ ????@Nullable ????@Override ????public?View?onCreateView(LayoutInflater?inflater,?@Nullable?ViewGroup?container,?@Nullable?Bundle?savedInstanceState)?{ ????????View?view2=inflater.inflate(R.layout.layout02,container,false); ????????return?view2; ????} }Fragment03public?class?Fragment03?extends?Fragment?{ ????@Nullable ????@Override ????public?View?onCreateView(LayoutInflater?inflater,?@Nullable?ViewGroup?container,?@Nullable?Bundle?savedInstanceState)?{ ????????View?view3=inflater.inflate(R.layout.layout03,container,false); ????????return?view3; ????} }MyAdapterpublic?class?MyAdapter?extends?FragmentPagerAdapter?{ ????private?List<Fragment>?fragmentList; ????public?myAdapter(FragmentManager?fm,?List<Fragment>?fragmentList)?{ ????????super(fm); ????????this.fragmentList?=?fragmentList; ????} ????@Override ????public?Fragment?getItem(int?position)?{ ????????return?fragmentList.get(position); ????} ????@Override ????public?int?getCount()?{ ????????return?fragmentList.size(); ????} }MainActivitypublic?class?MainActivity?extends?Activity?{ ????private?List<Fragment>?fragmentList; ????private?ViewPager?viewPager; ????private?Fragment?fragment01,fragment02,fragment03; ????private?myAdapter?myAdapter; ????@Override ????protected?void?onCreate(Bundle?savedInstanceState)?{ ????????super.onCreate(savedInstanceState); ????????setContentView(R.layout.activity_main); ????????fragmentList=new?ArrayList<>(); ????????viewPager=(ViewPager)findViewById(R.id.view_pager); ????????fragmentList.add(fragment01); ????????fragmentList.add(fragment02); ????????fragmentList.add(fragment03); ????????myAdapter=new?myAdapter(getSupportFragmentManager(),fragmentList); ????????viewPager.setAdapter(myAdapter); ????} }
查看完整描述

3 回答

已采納
?
蜂之谷

TA貢獻(xiàn)564條經(jīng)驗(yàn) 獲得超863個(gè)贊

fragment01,fragment02,fragment03 沒(méi)有初始化呀

查看完整回答
反對(duì) 回復(fù) 2017-06-12
  • 3 回答
  • 0 關(guān)注
  • 1441 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)