Ejemplo n.º 1
0
 @SuppressLint("InflateParams")
 private void initPageView() {
   pageView = LayoutInflater.from(getActivity()).inflate(R.layout.index_outline, null);
   viewPager = (CarouselViewPager) pageView.findViewById(R.id.vp_main);
   pageCarouselAdapter = new PageCarouselAdapter(getActivity());
   pageCarouselAdapter.setPostBeans(focusData);
   viewPager.setAdapter(pageCarouselAdapter);
   indicatorLayout = (IndicatorLayout) pageView.findViewById(R.id.indicate_main);
   indicatorLayout.setViewPage(viewPager);
   listView.getRefreshableView().addHeaderView(pageView, null, false);
 }
Ejemplo n.º 2
0
 @Override
 public void onResume() {
   super.onResume();
   Util.setStatusBarColor(getActivity());
   // 设置标题
   TextView titleTextView = (TextView) getActivity().findViewById(R.id.header_textview);
   titleTextView.setText("今日新闻");
   // 改变ViewPager高度按16:9
   viewPager.post(
       new Runnable() {
         @Override
         public void run() {
           int width = viewPager.getWidth();
           if (width == 0) return;
           int height = width * 9 / 16;
           viewPager.setLayoutParams(new RelativeLayout.LayoutParams(width, height));
         }
       });
   // 每隔5秒钟切换一张图片
   startViewPagerTask();
 }