コード例 #1
0
ファイル: UITableView.java プロジェクト: huaj12/weguan
  public void commit() {
    mIndexController = 0;

    if (mItemList.size() > 1) {
      // when the list has more than one item
      for (IListItem obj : mItemList) {
        View tempItemView;
        if (mIndexController == 0) {
          tempItemView = mInflater.inflate(R.layout.uitable_list_item_top, null);
        } else if (mIndexController == mItemList.size() - 1) {
          tempItemView = mInflater.inflate(R.layout.uitable_list_item_bottom, null);
        } else {
          tempItemView = mInflater.inflate(R.layout.uitable_list_item_middle, null);
        }
        setupItem(tempItemView, obj, mIndexController);
        tempItemView.setClickable(obj.isClickable());
        mListContainer.addView(tempItemView);
        mIndexController++;
      }
    } else if (mItemList.size() == 1) {
      // when the list has only one item
      View tempItemView = mInflater.inflate(R.layout.uitable_list_item_single, null);
      IListItem obj = mItemList.get(0);
      setupItem(tempItemView, obj, mIndexController);
      tempItemView.setClickable(obj.isClickable());
      mListContainer.addView(tempItemView);
    }
  }
コード例 #2
0
  @Test
  public void testClickable() {
    assertFalse(view.isClickable());

    view.setClickable(true);
    assertTrue(view.isClickable());

    view.setClickable(false);
    assertFalse(view.isClickable());
  }
コード例 #3
0
 @Override
 public void onTextChanged(CharSequence s, int start, int before, int count) {
   if (checkNextClickable()) {
     next_stepView.setClickable(true);
     next_stepView.setBackgroundResource(R.drawable.blue_retancle_button_selector);
   } else {
     next_stepView.setClickable(false);
     next_stepView.setBackgroundResource(R.color.vd0d0d0);
   }
 }
コード例 #4
0
ファイル: SwipeMenu.java プロジェクト: ywg228/AndroidCommon
 @Override
 protected void onLayout(boolean b, int i, int i1, int i2, int i3) {
   if (b) {
     mContentView.setClickable(true);
     mMenuView.setClickable(true);
     mMenuView.setBackgroundColor(Color.TRANSPARENT);
     mMenuView.layout(0, 0, mScreenWidth - mMenuOffset, mScreenHeight);
     mContentView.layout(
         mScreenWidth - mMenuOffset, 0, mScreenWidth - mMenuOffset + mScreenWidth, mScreenHeight);
     scrollTo(mScreenWidth - mMenuOffset, 0);
   }
 }
コード例 #5
0
  @Override
  public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    final ListView listView = getListView();
    final View loaderView =
        LayoutInflater.from(getActivity()).inflate(R.layout.list_item_loader, null);
    loaderView.setEnabled(false);
    loaderView.setClickable(false);
    loaderView.setFocusable(false);
    loaderView.setFocusableInTouchMode(false);

    addOnScrollListener(
        new OnScrollListener() {
          @Override
          public void onScrollStateChanged(final AbsListView view, final int scrollState) {}

          @Override
          public void onScroll(
              final AbsListView view,
              final int firstVisibleItem,
              final int visibleItemCount,
              final int totalItemCount) {
            final int lastInScreen = firstVisibleItem + visibleItemCount;
            if ((lastInScreen == totalItemCount) && listView.getAdapter() != null) {
              onLoadMoreItems();
            }
          }
        });

    listView.addFooterView(loaderView);
  }
コード例 #6
0
ファイル: StylusPlugin.java プロジェクト: rhomobile/rhodes
  /** Method to disable the touch screen , it works by consuming WebView touch events */
  public void enableOnClickEvents(final boolean isEnabled) {
    Common.getWebView()
        .setOnTouchListener(
            new View.OnTouchListener() {

              @Override
              public boolean onTouch(View arg0, MotionEvent arg1) {
                return !isEnabled;
              }
            });
    ViewGroup mainView = (ViewGroup) Common.getMainView();
    for (int i = 0; i < mainView.getChildCount(); i++) {
      if (mainView.getChildAt(i) instanceof AbsoluteLayout) {
        ViewGroup buttonContainer = (ViewGroup) mainView.getChildAt(i);
        for (int j = 0; j < buttonContainer.getChildCount(); j++) {
          View childView = buttonContainer.getChildAt(j);
          if ((childView instanceof Button)
              || // button case
              (childView instanceof AutoCompleteTextView)) // address bar case
          {
            childView.setClickable(isEnabled); // set all the (debug) buttons or the address bar
          }
        }
      }
    }
  }
コード例 #7
0
ファイル: TestFragment.java プロジェクト: humorboy/mg-waiter
 private void initUI(final View root) {
   root.setClickable(true);
   root.setOnClickListener(
       new OnClickListener() {
         @Override
         public void onClick(View v) {}
       });
   tv = (TextView) root.findViewById(R.id.textView);
   contentTv = (TextView) root.findViewById(R.id.content_tv);
   locationTv = (TextView) root.findViewById(R.id.location_tv);
   timeTv = (TextView) root.findViewById(R.id.time_tv);
   root.findViewById(R.id.button)
       .setOnClickListener(
           new OnClickListener() {
             @Override
             public void onClick(View v) {
               root.setClickable(false);
               ViewPropertyAnimator.animate(root)
                   .rotationY(-90)
                   .setDuration(200)
                   .setListener(
                       new AnimatorListenerAdapter() {
                         @Override
                         public void onAnimationEnd(Animator animation) {
                           root.clearAnimation();
                           root.setVisibility(View.INVISIBLE);
                           view.setEnabled(true);
                         }
                       });
             }
           });
 }
コード例 #8
0
ファイル: EventNewsFragment.java プロジェクト: Tieru/Bizon
  @Override
  public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    view.setClickable(true);

    Bundle bundle = getArguments();
    if (bundle == null) {
      return;
    }

    mEvent = (Event) bundle.getSerializable(ARG_EVENT);

    mListView = (ListView) view.findViewById(R.id.listView);
    mListView.setOnScrollListener(new ScrollListener());
    mAdapter = new EventNewsAdapter();
    mListView.setAdapter(mAdapter);
    mLoaderCallback = new EventNewsLoaderCallback();
    mRestService = HttpHelper.getRestAdapter().create(RestHelper.class);

    Profile profile = User.currentUser().getProfile();
    if (profile != null && profile.getIsAdmin() == 1) {
      setHasOptionsMenu(true);
      registerForContextMenu(mListView);
    }

    onLoadBegins();
    loadEventNews(0);
  }
コード例 #9
0
ファイル: SubsonicActivity.java プロジェクト: mesuk/Subsonic
 public void updateDrawerHeader() {
   if (Util.isOffline(this)) {
     drawerServerName.setText(R.string.select_album_offline);
     drawerUserName.setText("");
     drawerUserAvatar.setVisibility(View.GONE);
     drawerHeader.setClickable(false);
     drawerHeaderToggle.setVisibility(View.GONE);
   } else {
     drawerServerName.setText(Util.getServerName(this));
     drawerUserName.setText(UserUtil.getCurrentUsername(this));
     drawerUserAvatar.setVisibility(View.VISIBLE);
     getImageLoader().loadAvatar(this, drawerUserAvatar, UserUtil.getCurrentUsername(this));
     drawerHeader.setClickable(true);
     drawerHeaderToggle.setVisibility(View.VISIBLE);
   }
 }
コード例 #10
0
  /**
   * Sets the Empty View to be used by the Adapter View.
   *
   * <p>We need it handle it ourselves so that we can Pull-to-Refresh when the Empty View is shown.
   *
   * <p>Please note, you do <strong>not</strong> usually need to call this method yourself. Calling
   * setEmptyView on the AdapterView will automatically call this method and set everything up. This
   * includes when the Android Framework automatically sets the Empty View based on it's ID.
   *
   * @param newEmptyView - Empty View to be used
   */
  public final void setEmptyView(View newEmptyView) {
    FrameLayout refreshableViewWrapper = getRefreshableViewWrapper();

    if (null != newEmptyView) {
      // New view needs to be clickable so that Android recognizes it as a
      // target for Touch Events
      newEmptyView.setClickable(true);

      ViewParent newEmptyViewParent = newEmptyView.getParent();
      if (null != newEmptyViewParent && newEmptyViewParent instanceof ViewGroup) {
        ((ViewGroup) newEmptyViewParent).removeView(newEmptyView);
      }

      // We need to convert any LayoutParams so that it works in our
      // FrameLayout
      FrameLayout.LayoutParams lp = convertEmptyViewLayoutParams(newEmptyView.getLayoutParams());
      if (null != lp) {
        refreshableViewWrapper.addView(newEmptyView, lp);
      } else {
        refreshableViewWrapper.addView(newEmptyView);
      }
    }

    if (mRefreshableView instanceof EmptyViewMethodAccessor) {
      ((EmptyViewMethodAccessor) mRefreshableView).setEmptyViewInternal(newEmptyView);
    } else {
      mRefreshableView.setEmptyView(newEmptyView);
    }
    mEmptyView = newEmptyView;
  }
コード例 #11
0
 public ViewHolder(View itemView) {
   super(itemView);
   itemView.setClickable(true);
   itemView.setOnClickListener(this);
   exerciseName = (TextView) itemView.findViewById(R.id.exercise_name);
   exerciseTime = (TextView) itemView.findViewById(R.id.exercise_time);
 }
コード例 #12
0
  /**
   * Sets the Empty View to be used by the Adapter View.
   *
   * <p>We need it handle it ourselves so that we can Pull-to-Refresh when the Empty View is shown.
   *
   * <p>Please note, you do <strong>not</strong> usually need to call this method yourself. Calling
   * setEmptyView on the AdapterView will automatically call this method and set everything up. This
   * includes when the Android Framework automatically sets the Empty View based on it's ID.
   *
   * @param newEmptyView - Empty View to be used
   */
  public final void setEmptyView(View newEmptyView) {
    // If we already have an Empty View, remove it
    if (null != mEmptyView) {
      mRefreshableViewHolder.removeView(mEmptyView);
    }

    if (null != newEmptyView) {
      // New view needs to be clickable so that Android recognizes it as a
      // target for Touch Events
      newEmptyView.setClickable(true);

      final ViewParent newEmptyViewParent = newEmptyView.getParent();
      if (null != newEmptyViewParent && newEmptyViewParent instanceof ViewGroup) {
        ((ViewGroup) newEmptyViewParent).removeView(newEmptyView);
      }

      mRefreshableViewHolder.addView(
          newEmptyView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

      if (mRefreshableView instanceof EmptyViewMethodAccessor) {
        ((EmptyViewMethodAccessor) mRefreshableView).setEmptyViewInternal(newEmptyView);
      } else {
        mRefreshableView.setEmptyView(newEmptyView);
      }
    }
  }
コード例 #13
0
  void _reloadViewsOnUiThread() {
    removeAllViews();
    if (mAdapter == null) return;

    final int groupCount = mAdapter.getGroupCount();
    mExpandedGroups = new boolean[groupCount];
    mGroups = new View[groupCount];
    mChildren = new View[groupCount][];

    for (int groupPosition = 0; groupPosition < groupCount; groupPosition++) {
      // add divider
      if (groupPosition != 0) addView(getDivider());

      // add group header
      View groupView = mAdapter.getGroupView(groupPosition, true, null, this);
      mGroups[groupPosition] = groupView;
      groupView.setClickable(true);
      final int finalGroupPosition = groupPosition;
      groupView.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              toggleGroup(finalGroupPosition);
            }
          });
      addView(groupView);
    }
  }
コード例 #14
0
  @Override
  public void onFinishInflate() {
    super.onFinishInflate();

    if (getChildCount() != 2) {
      throw new RuntimeException(BGARefreshLayout.class.getSimpleName() + "必须有且只有一个子控件");
    }

    mContentView = getChildAt(1);
    if (mContentView instanceof AbsListView) {
      mAbsListView = (AbsListView) mContentView;
    } else if (mContentView instanceof RecyclerView) {
      mRecyclerView = (RecyclerView) mContentView;
    } else if (mContentView instanceof ScrollView) {
      mScrollView = (ScrollView) mContentView;
    } else if (mContentView instanceof WebView) {
      mWebView = (WebView) mContentView;
    } else if (mContentView instanceof BGAStickyNavLayout) {
      mStickyNavLayout = (BGAStickyNavLayout) mContentView;
      mStickyNavLayout.setRefreshLayout(this);
    } else {
      mNormalView = mContentView;
      // 设置为可点击,否则在空白区域无法拖动
      mNormalView.setClickable(true);
    }
  }
コード例 #15
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_gridview);
    ObservableGridView scrollable = (ObservableGridView) findViewById(R.id.scrollable);
    // Set padding view for GridView. This is the flexible space.
    headerView = new View(this);
    final int flexibleSpaceImageHeight =
        getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height);
    FrameLayout.LayoutParams lp =
        new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT, flexibleSpaceImageHeight);
    headerView.setLayoutParams(lp);

    // This is required to disable header's list selector effect
    headerView.setClickable(true);

    scrollable.addHeaderView(headerView);
    scrollable.setScrollViewCallbacks(this);
    UiTestUtils.setDummyData(this, scrollable);
    scrollable.setOnScrollListener(
        new AbsListView.OnScrollListener() {
          @Override
          public void onScrollStateChanged(AbsListView view, int scrollState) {}

          @Override
          public void onScroll(
              AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {}
        });
  }
コード例 #16
0
ファイル: CourseListAdapter.java プロジェクト: Kinderfest/Uni
  @Override
  public View getChildView(
      final int groupPosition,
      final int childPosition,
      boolean isLastChild,
      View convertView,
      final ViewGroup parent) {

    if (convertView == null) {
      LayoutInflater inflate =
          (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      convertView = inflate.inflate(R.layout.grips_list_item, parent, false);
    }
    TextView title = (TextView) convertView.findViewById(R.id.list_item_name);
    title.setText(((Link) getChild(groupPosition, childPosition)).getName());
    convertView.setClickable(true);
    convertView.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            ((GripsActivity) activity)
                .parseSingleItem(((Link) getChild(groupPosition, childPosition)));
          }
        });

    return convertView;
  }
コード例 #17
0
 /**
  * Set the draggable view portion. Use to null, to allow the whole panel to be draggable
  *
  * @param dragView A view that will be used to drag the panel.
  */
 public void setDragView(View dragView) {
   if (mDragView != null) {
     mDragView.setOnClickListener(null);
   }
   mDragView = dragView;
   if (mDragView != null) {
     mDragView.setClickable(true);
     mDragView.setFocusable(false);
     mDragView.setFocusableInTouchMode(false);
     mDragView.setOnClickListener(
         new OnClickListener() {
           @Override
           public void onClick(View v) {
             if (!isEnabled() || !isTouchEnabled()) return;
             if (mSlideState != PanelState.EXPANDED && mSlideState != PanelState.ANCHORED) {
               if (mAnchorPoint < 1.0f) {
                 setPanelState(PanelState.ANCHORED);
               } else {
                 setPanelState(PanelState.EXPANDED);
               }
             } else {
               setPanelState(PanelState.COLLAPSED);
             }
           }
         });
     ;
   }
 }
コード例 #18
0
 private void onCreateWorker() {
   theater = getIntent().getExtras().getParcelable("theater");
   movies = getService().getMoviesAtTheater(theater);
   populateTheaterDetailEntries();
   final TextView titleView = (TextView) findViewById(R.id.theater);
   titleView.setText(theater.getName());
   final View linearLayout = findViewById(R.id.header);
   final ImageView ratingImage = (ImageView) findViewById(R.id.ratingImage);
   final Resources res = getResources();
   if (getService().isFavoriteTheater(theater)) {
     ratingImage.setImageDrawable(res.getDrawable(R.drawable.rate_star_big_on));
   } else {
     ratingImage.setImageDrawable(res.getDrawable(R.drawable.rate_star_big_off));
   }
   linearLayout.setClickable(true);
   linearLayout.setOnClickListener(
       new View.OnClickListener() {
         public void onClick(final View view) {
           if (getService().isFavoriteTheater(theater)) {
             ratingImage.setImageDrawable(res.getDrawable(R.drawable.rate_star_big_off));
             getService().removeFavoriteTheater(theater);
           } else {
             ratingImage.setImageDrawable(res.getDrawable(R.drawable.rate_star_big_on));
             getService().addFavoriteTheater(theater);
           }
         }
       });
   setListAdapter(new TheaterDetailsAdapter());
 }
コード例 #19
0
  public void addActionItem(ActionItem action) {

    String title = action.getTitle();
    Drawable icon = action.getIcon();

    View container = (View) inflater.inflate(R.layout.action_item, null);

    ImageView img = (ImageView) container.findViewById(R.id.iv_icon);
    TextView text = (TextView) container.findViewById(R.id.tv_title);

    if (icon != null) img.setImageDrawable(icon);
    else img.setVisibility(View.GONE);

    if (title != null) text.setText(title);
    else text.setVisibility(View.GONE);

    final int pos = mChildPos;

    container.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            if (mListener != null) mListener.onItemClick(pos);

            dismiss();
          }
        });

    container.setFocusable(true);
    container.setClickable(true);

    mTrack.addView(container, mChildPos + 1);

    mChildPos++;
  }
コード例 #20
0
  private void setupNavigationView() {

    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    NavigationView navigationView = (NavigationView) findViewById(R.id.navigation_view);
    if (navigationView != null) {
      setupDrawerContent(navigationView, this);
    }
    View header = findViewById(R.id.header);
    header.setClickable(true);
    final CircleImageView userPhoto = (CircleImageView) findViewById(R.id.user_photo);
    userPhoto.setClickable(true);
    userPhoto.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Log.d(TAG, MyUser.userId);
            if ("001".equals(MyUser.userId)) {
              drawerLayout.closeDrawers();
              showLoginDialog();
            } else {
              Intent intent = new Intent(MainActivity.this, UserAcitivity.class);
              intent.putExtra("userId", mUser.getUserId());
              startActivity(intent);
            }
          }
        });
  }
コード例 #21
0
          @Override
          public void onClick(View v) {
            AdminMessage msg = (AdminMessage) v.getTag();
            currMsg = msg;

            if (mGItem != null) {
              mGItem.Cancel();
            }
            mGItem = new TGroupInfoItem();
            mGItem.SetListener(MyAdapter.this, null);
            mGItem.SetID(msg.roomid);
            boolean boo = false;
            String str = null;
            if (msg.no == 100) { // 被邀请
              str = getString(R.string.group_fail);
              boo = mGItem.RequestEnterGroup("");
            } else if (msg.no == 101) { // 别人申请加入
              str = getString(R.string.addgroup_fail);
              boo = mGItem.AcceptUserApply(msg.fromid);
            }
            if (!boo && str != null) {
              Toast.makeText(getActivity(), str, Toast.LENGTH_SHORT).show();
              return;
            }
            startWait();
            v.setClickable(false);
          }
コード例 #22
0
  public static void openMenu(int type, final Activity context, final View layout, final int id) {
    Animation anim = null;
    switch (type) {
      case RIGHT_LEFT:
        anim = AnimationUtils.loadAnimation(context, R.anim.right_to_left_menu_show);
        break;
      case UP_DOWN:
        anim = AnimationUtils.loadAnimation(context, R.anim.up_to_down_menu_show);
        break;
    }
    if (layout != null) {
      final View left = layout.findViewById(id);
      layout.setVisibility(View.VISIBLE);
      left.setVisibility(View.INVISIBLE);
      layout.startAnimation(anim);
      layout.setClickable(true);
      layout.setFocusable(true);
      setEnable(false, context);
      anim.setAnimationListener(
          new AnimationListener() {

            @Override
            public void onAnimationStart(Animation arg0) {}

            @Override
            public void onAnimationRepeat(Animation arg0) {}

            @Override
            public void onAnimationEnd(Animation arg0) {
              left.setVisibility(View.VISIBLE);
              setEnable(true, context);
            }
          });
    }
  }
コード例 #23
0
ファイル: LoginActivity.java プロジェクト: unicefjpr/ejan
 private void localLogin(View view, String userName, String password) {
   if (context.userService().isValidLocalLogin(userName, password)) {
     localLoginWith(userName, password);
   } else {
     showErrorDialog(getString(R.string.login_failed_dialog_message));
     view.setClickable(true);
   }
 }
コード例 #24
0
 // LinearLayout下所有childView 可点击开关
 // 当动画在播放时应该设置为不可点击,结束时设置为可点击
 private void onOffClickable(boolean isClickable) {
   View child;
   int childCount = mSliding.getChildCount();
   for (int i = 0; i < childCount; i++) {
     child = mSliding.getChildAt(i);
     child.setClickable(isClickable);
   }
 }
コード例 #25
0
ファイル: UIUtils.java プロジェクト: ysyh55/beiyue
 public static void setAccessibilityIgnore(View view) {
   view.setClickable(false);
   view.setFocusable(false);
   view.setContentDescription("");
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
     view.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
   }
 }
コード例 #26
0
 @Override
 public void onClick(View v) {
   addToCarOrder(goodItemBean);
   //			Toast.makeText(context, "添加成功!", Toast.LENGTH_LONG).show();
   new MessageDialog(context, "添加成功!请转到购物车付款").show();
   // v.setBackgroundColor(context.getResources().getColor(R.color.black));
   v.setClickable(false);
 }
コード例 #27
0
  @Override
  public View getGroupView(
      int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {

    View row = null;
    TextView tvTitleLine02;
    Typeface font;
    if (groupPosition == 0) {
      // Styles for the header group

      row = null;

      // if (row == null) {
      if (row == null) {
        LayoutInflater inflater =
            (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        row = inflater.inflate(R.layout.row_header, parent, false);
      }

      tvTitleLine02 = (TextView) row.findViewById(R.id.tvTitleLine02);
      font =
          Typeface.createFromAsset(((Activity) this.context).getAssets(), "font/p22-corinthia.ttf");
      tvTitleLine02.setTypeface(font);

      row.setClickable(false);

      return row;

    } else {

      // row = convertView;

      if (row == null) {
        LayoutInflater inflater =
            (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        row = inflater.inflate(R.layout.row_category_list, parent, false);
      }

      TextView tvGroup = (TextView) row.findViewById(R.id.tvPrayerListTitle);

      if (tvGroup != null) {
        // tvGroup.setText(parentList[groupPosition]);
        tvGroup.setText(categoryList.get(groupPosition).getName());
      }

      ImageView indicator = (ImageView) row.findViewById(R.id.ivPrayerListGroupIndicator);

      if (indicator != null) {
        if (isExpanded) {
          indicator.setImageResource(R.drawable.minus_yellow_01);
        } else {
          indicator.setImageResource(R.drawable.plus_yellow_01);
        }
      }

      return row;
    }
  }
コード例 #28
0
 public void setClickable(boolean clickable) {
   TiUIView v = peekView();
   if (v != null) {
     View nv = v.getNativeView();
     if (nv != null) {
       nv.setClickable(clickable);
     }
   }
 }
コード例 #29
0
 public MessageViewHolder(View v, ViewGroup viewGroup) {
   super(v);
   v.setClickable(true);
   cv = (CardView) v.findViewById(R.id.cv_message);
   vTitle = (TextView) v.findViewById(R.id.txtTitle);
   vContent = (TextView) v.findViewById(R.id.txtContent);
   vImg = (ImageView) v.findViewById(R.id.imgMessage);
   this.viewGroup = viewGroup;
 }
コード例 #30
0
  /**
   * Add action item
   *
   * @param action {@link ActionItem}
   */
  public void addActionItem(QuickActionItem action) {
    mActionItemList.add(action);

    String title = action.getTitle();
    Drawable icon = action.getIcon();

    View container = (View) inflater.inflate(R.layout.action_item, null);

    ImageView img = (ImageView) container.findViewById(R.id.iv_icon);
    TextView text = (TextView) container.findViewById(R.id.tv_title);

    if (icon != null) {
      img.setImageDrawable(icon);
    } else {
      img.setVisibility(View.GONE);
    }

    if (title != null) {
      text.setText(title);
    } else {
      text.setVisibility(View.GONE);
    }

    final int pos = mChildPos;
    final int actionId = action.getActionId();

    container.setOnClickListener(
        new OnClickListener() {
          // @Override
          public void onClick(View v) {
            if (mItemClickListener != null) {
              mItemClickListener.onItemClick(QuickAction.this, pos, actionId);
            }

            if (!getActionItem(pos).isSticky()) {
              mDidAction = true;

              // workaround for transparent background bug
              // thx to Roman Wozniak <*****@*****.**>
              v.post(
                  new Runnable() {
                    // @Override
                    public void run() {
                      dismiss();
                    }
                  });
            }
          }
        });

    container.setFocusable(true);
    container.setClickable(true);

    mTrack.addView(container, mChildPos + 1);

    mChildPos++;
  }