首先我必須說對不起,我的英語不是很好我必須在擴展片段中在頂部添加 tablayout 和 ViewPage給ViewPageAdapter添加三個Fragment來切換ViewPage但我目前無法知道為什么我的適配器在模擬器上顯示為空我找到了一些文章,但我不知道哪一篇適合我目前的情況。麻煩大家給個回復和建議我會虛心接受,謝謝!這是我的 XML<?xml version="1.0" encoding="utf-8"?><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"xmlns:app="http://schemas.android.com/apk/res-auto"tools:context=".HomeFragment"><android.support.design.widget.TabLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/colorPrimary" app:tabMode="fixed" app:tabGravity="fill" app:tabIndicatorColor="@color/colorAccent" android:id="@+id/tablayout_fragment_home" ></android.support.design.widget.TabLayout><android.support.v4.view.ViewPager android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/viewpager_fragment_home"/></FrameLayout>這是我的.javapackage com.example.teng.myapplication;import android.content.Intent;import android.os.Bundle;import android.support.design.widget.TabLayout;import android.support.v4.app.Fragment;import android.support.v4.view.ViewPager;import android.util.Log;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;public class HomeFragment extends android.support.v4.app.Fragment {View view ;private TabLayout tabLayout;private ViewPager viewPager;private ViewPagerAdapter adapter;public HomeFragment() { // Required empty public constructor}@Overridepublic View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment view = inflater.inflate(R.layout.fragment_home, container, false); return view ;}
添加回答
舉報
0/150
提交
取消