Пример #1
0
  private void initGallery() {
    imgList = new ArrayList<>();
    imgList.add(R.drawable.sy_yjqb);
    imgList.add(R.drawable.xb);
    restaurant_orderseat_img_container =
        (LinearLayout) mView.findViewById(R.id.restaurant_orderseat_img_container);
    ipaAdapter = new GalleryAdapter(activity, imgList, restaurant_orderseat_img_container);
    restaurant_orderseat_image.setAdapter(ipaAdapter);
    restaurant_orderseat_image.setFocusable(true);
    restaurant_orderseat_image.startTimer(3000);
    intent = new Intent();
    intent.setFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
    restaurant_orderseat_image.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (position % imgList.size()) {
              case 0:
                intent.putExtra("title", "去钓鱼岛");
                intent.setClass(getActivity(), WholeBookActivity.class);
                startActivity(intent);
                break;
              case 1:
                intent.putExtra("title", "去钓鱼岛");
                intent.setClass(getActivity(), WholeBookActivity.class);
                startActivity(intent);
                break;
            }
          }
        });
    restaurant_orderseat_image.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            position = position % imgList.size();
            if (imgList.size() > 1) {
              // 修改上一次选中项的背景
              ImageView preSelImg =
                  (ImageView) restaurant_orderseat_img_container.findViewById(preSelImgIndex);
              preSelImg.setImageResource(R.drawable.ic_focus);
              // 修改当前选中项的背景
              ImageView curSelImg =
                  (ImageView) restaurant_orderseat_img_container.findViewById(position);
              curSelImg.setImageResource(R.drawable.ic_focus_green_select);
              // text_hotelName.setText(selIndex + "");
              preSelImgIndex = position;
            }
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {}
        });
  }
Пример #2
0
  /**
   * **********************************************
   *
   * @param r 设定文件
   * @return void 返回类型
   * @throws @Title: fastResult @Description: (酒店楼宇接口 返回)
   * @date 2014-11-19 ***********************************************
   */
  @InjectHttpOk(value = {111})
  protected void fastResult(ResponseEntity r) {
    System.out.println(r.getStatus());
    switch (r.getStatus()) {
      case FastHttp.result_ok:
        if (ResultParse.reservationIsResultOK(r, activity)) {
          imgList = Handler_Json.JsonToCollection(r.getContentAsString());
          // InitFocusIndicatorContainer();
          // initGallery();
          ipaAdapter = new ImagePagerAdapter(activity, imgList, indicator_container);

          gallery_hotel.setAdapter(ipaAdapter);
          ipaAdapter.notifyDataSetChanged();
          gallery_hotel.setFocusable(true);
        }
        break;
      case FastHttp.result_net_err:
        Toast.makeText(activity, "网络异常 ,请检查您确保开启无线网络", Toast.LENGTH_SHORT).show();
        break;
    }
  }