首先我必须说对不起,我的英语不是很好我必须在扩展片段中在顶部添加 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
提交
取消