Ejemplo n.º 1
0
  private void initXListViewHeader() {
    View headView = LayoutInflater.from(mContext).inflate(R.layout.home_xgridview_header, null);
    convenientBanner = (ConvenientBanner) headView.findViewById(R.id.convenientBanner);
    convenientBanner.setLayoutParams(
        new XListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 600));
    convenientBanner
        .setPages(
            new CBViewHolderCreator<NetworkImageHolderView>() {
              @Override
              public NetworkImageHolderView createHolder() {
                return new NetworkImageHolderView();
              }
            },
            networkImages)
        .setPageIndicator(
            new int[] {R.drawable.ic_page_indicator, R.drawable.ic_page_indicator_focused});

    convenientBanner.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(int position) {
            ToastUtil.showToast(mContext, "点击了--position" + position + "---type" + mType);
          }
        });

    home_Xlistview.addHeaderView(convenientBanner);
    // 开始自动翻页
    convenientBanner.startTurning(3000);
  }
Ejemplo n.º 2
0
  private void fillData(String result) {
    DealData dealData = null;
    try {
      dealData = GsonUtil.json2bean(result, DealData.class);
      ArrayList<Deal> deals = dealData.getData().getDeals();

      if (isRefresh) {
        mAllDeals.clear();
        convenientBanner.setcurrentitem(0);
      }
      mAllDeals.addAll(deals);
      if (newsListAdapter == null) {
        newsListAdapter = new TabListAdapter(mContext, mAllDeals);
        home_Xlistview.setAdapter(newsListAdapter);
      } else {
        newsListAdapter.setData(mAllDeals);
        newsListAdapter.notifyDataSetChanged();
      }
      mHandler.sendEmptyMessage(MSG_STOP_REFRESH);
      home_Xlistview.setVisibility(View.VISIBLE);
      hideBaseLoading();

    } catch (Exception e) {
      hideBaseLoading();
      if (mAllDeals.size() == 0 && !isRefresh) {
        showLoadingError();
      } else {
        mHandler.sendEmptyMessage(MSG_STOP_REFRESH);
        ToastUtil.showToast(mContext, "亲,加载错误啦,请重试.");
      }
      e.printStackTrace();
    }
  }
Ejemplo n.º 3
0
 @Override
 public void onDestroyView() {
   super.onDestroyView();
   Log.i("abc", "tab--onDestroyView>" + mType);
   mAllDeals.clear();
   if (convenientBanner != null) {
     boolean result = home_Xlistview.removeHeaderView(convenientBanner);
   }
   home_Xlistview.setVisibility(View.GONE);
   // 停止翻页
   convenientBanner.stopTurning();
 }