@Override
  public View onCreateView(
      LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.movie_fragment_vp, container, false);
    Bundle bundle = getArguments();
    int i = bundle.getInt("id");
    lv = (ListView) view.findViewById(R.id.movie_list);

    ;
    final View head = inflater.inflate(R.layout.movie_listhead, null);
    lv.addHeaderView(head);
    HttpUtils.getResult(
        url + i,
        new StringGetData() {
          @Override
          public void getStringData(String s) {
            list = ParseJson.getListItem(s);
            Movie_List_Adapter adapter = new Movie_List_Adapter(getActivity(), list);
            lv.setAdapter(adapter);
            initHead(head);
          }
        });

    return view;
  }
Exemple #2
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_movies, container, false);
    movievp = (ViewPager) view.findViewById(R.id.movie_vp);
    monthIv = (ImageView) view.findViewById(R.id.months);
    date2Iv = (ImageView) view.findViewById(R.id.data2);
    weekIv = (ImageView) view.findViewById(R.id.week);

    // 获取系统当前时间
    int[] currentDate = CurrentTimeUtil.getCurrentDate();
    yearCurrent = currentDate[0];
    monthCurrent = currentDate[1];
    dayCurrent = currentDate[2];
    weekCurrent = currentDate[3];

    // 获得当前时间对应的图片的 postion
    int[] currentDatePic =
        CurrentTimeUtil.getCurrentDatePic(yearCurrent, monthCurrent, dayCurrent, weekCurrent);
    monthPostion = currentDatePic[0];
    dayPostion = currentDatePic[1];
    weekPostion = currentDatePic[2];

    // 第一个页面的图片
    monthIv.setImageResource(CurrentTimeUtil.monthPic[monthPostion]); // 月
    date2Iv.setImageResource(CurrentTimeUtil.listPicture.get(dayPostion)); // 日
    weekIv.setImageResource(CurrentTimeUtil.weekPic[weekPostion]); // 星期几

    HttpUtils.getResult(
        url,
        new StringGetData() {
          @Override
          public void getStringData(String s) {
            list = ParseJson.getInfo(s);
            initData();
          }
        });

    return view;
  }