Fragment如何获取view并运用Adapter编辑view

import android.app.Fragment;import android.content.Context;import android.os.Bundle;import android.support.v4.view.ViewPager;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import me.relex.circleindicator.CircleIndicator;/** * A simple {@link Fragment} subclass. */public class HomeFragment extends Fragment { //定义轮播和指示器 private ViewPager viewPager; private CircleIndicator indicator; private PicAdapter picAdapter; @Override public void onAttach(Context context) { super.onAttach(context); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { //获取view View view = inflater.inflate(R.layout.fragment_home, container, false); //初始化图片轮播 viewPager = (ViewPager)view.findViewById(R.id.home_viewpager); indicator = (CircleIndicator) view.findViewById(R.id.home_indicator); picAdapter = new PicAdapter(this); viewPager.setAdapter(picAdapter); //viewPager.setLooperPic(true); indicator.setViewPager(viewPager); return view ; }}

你可能感兴趣的:(fragment)