Java Code Examples for android.view.View.setClickable()

The following are Jave code examples for showing how to use setClickable() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: PingWidget   File: ThemePreference.java   View Source Code Vote up 6 votes
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    holder.itemView.setClickable(false);    // disable parent click

    //Loop through all the ThemeViews
    for(WidgetTheme widgetTheme : WidgetTheme.values()) {
        final String name = widgetTheme.name();
        final int themeViewId = widgetTheme.getThemeViewId();
        final int summaryRes = widgetTheme.getSummaryRes();

        View button = holder.findViewById(themeViewId);
        button.setClickable(true);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                setSummary(summaryRes);
                persistString(name);
            }
        });
    }
}
 
Example 2
Project: Toodoo   File: ToodooListAdapter.java   View Source Code Vote up 6 votes
public MyViewHolder(View itemView) {
    super(itemView);
    itemView.setClickable(true);
    layoutBackground = (LinearLayout) itemView.findViewById(R.id.main_background_view);
    layoutMain = (LinearLayout) itemView.findViewById(R.id.main_view);
    layoutDueDate = (LinearLayout) itemView.findViewById(R.id.layout_duedate);
    layoutLabel = (LinearLayout) itemView.findViewById(R.id.layout_label);
    layoutReminder = (LinearLayout) itemView.findViewById(R.id.layout_reminder);
    todoItem = (TextView) itemView.findViewById(R.id.todoTask);
    todoLabel = (TextView) itemView.findViewById(R.id.todoLabel);
    todoDueDate = (TextView) itemView.findViewById(R.id.todoDueDate);
    todoReminder = (TextView) itemView.findViewById(R.id.todoTime);
    iconLabel = (ImageView) itemView.findViewById(R.id.iconLabel);
}
 
Example 3
Project: XinFramework   File: SupportFragmentDelegate.java   View Source Code Vote up 6 votes
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    getVisibleDelegate().onActivityCreated(savedInstanceState);

    View view = mFragment.getView();
    if (view != null) {
        view.setClickable(true);
        setBackground(view);
    }

    if (savedInstanceState != null
            || mRootStatus == STATUS_ROOT_ANIM_DISABLE
            || (mFragment.getTag() != null && mFragment.getTag().startsWith("android:switcher:"))
            || (mReplaceMode && !mFirstCreateView)) {
        notifyEnterAnimEnd();
    } else if (mCustomEnterAnim != Integer.MIN_VALUE) {
        fixAnimationListener(mCustomEnterAnim == 0 ?
                mAnimHelper.getNoneAnim() : AnimationUtils.loadAnimation(_mActivity, mCustomEnterAnim));
    }

    if (mFirstCreateView) {
        mFirstCreateView = false;
    }
}
 
Example 4
Project: chromium-for-android-56-debug-video   File: TextAndButtonPreference.java   View Source Code Vote up 6 votes
@Override
protected void onBindView(View view) {
    super.onBindView(view);

    View button = view.findViewById(R.id.preference_click_target);
    button.setClickable(true);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (getOnPreferenceClickListener() != null) {
                getOnPreferenceClickListener().onPreferenceClick(TextAndButtonPreference.this);
            }
        }
    });
}
 
Example 5
Project: Cable-Android   File: ColorPreference.java   View Source Code Vote up 6 votes
private void repopulateItems() {
  if (mPreference == null || mColorGrid == null) {
    return;
  }

  Context context = mColorGrid.getContext();
  mColorGrid.removeAllViews();
  for (final int color : mPreference.mColorChoices) {
    View itemView = LayoutInflater.from(context)
                                  .inflate(R.layout.color_preference_item, mColorGrid, false);

    setColorViewValue(itemView.findViewById(R.id.color_view), color,
                      color == mPreference.getValue());
    itemView.setClickable(true);
    itemView.setFocusable(true);
    itemView.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
        mPreference.setValue(color);
        dismiss();
      }
    });

    mColorGrid.addView(itemView);
  }

  sizeDialog();
}
 
Example 6
Project: PeSanKita-android   File: ColorPreference.java   View Source Code Vote up 6 votes
private void repopulateItems() {
  if (mPreference == null || mColorGrid == null) {
    return;
  }

  Context context = mColorGrid.getContext();
  mColorGrid.removeAllViews();
  for (final int color : mPreference.mColorChoices) {
    View itemView = LayoutInflater.from(context)
                                  .inflate(R.layout.color_preference_item, mColorGrid, false);

    setColorViewValue(itemView.findViewById(R.id.color_view), color,
                      color == mPreference.getValue());
    itemView.setClickable(true);
    itemView.setFocusable(true);
    itemView.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
        mPreference.setValue(color);
        dismiss();
      }
    });

    mColorGrid.addView(itemView);
  }

  sizeDialog();
}
 
Example 7
Project: PeSanKita-android   File: AnimatingToggle.java   View Source Code Vote up 6 votes
@Override
public void addView(@NonNull View child, int index, ViewGroup.LayoutParams params) {
  super.addView(child, index, params);

  if (getChildCount() == 1) {
    current = child;
    child.setVisibility(View.VISIBLE);
  } else {
    child.setVisibility(View.GONE);
  }
  child.setClickable(false);
}
 
Example 8
Project: Beach-Android   File: ContactAdapter.java   View Source Code Vote up 6 votes
public ViewHolder(View itemView, int viewType, Context c) {
    super(itemView);

    itemView.setClickable(true);
    ivContactImage = (ImageView) itemView.findViewById(R.id.ivContactImage);
    tvContactName = (TextView) itemView.findViewById(R.id.tvContactName);
}
 
Example 9
Project: PullToRefreshRecyclerView   File: PullToRefreshRecyclerView.java   View Source Code Vote up 6 votes
@Override
public void onChildAttachedToWindow(View child) {
    super.onChildAttachedToWindow(child);
    if (!ViewCompat.hasOnClickListeners(child)) {
        child.setClickable(true);
        child.setOnClickListener(mOnItemOperateListenerInternalInternal);
    }
    child.setOnLongClickListener(mOnItemOperateListenerInternalInternal);
}
 
Example 10
Project: RLibrary   File: RBaseSwipeAdapter.java   View Source Code Vote up 6 votes
@NonNull
@Override
protected RBaseViewHolder createBaseViewHolder(int viewType, View itemView) {
    if (itemView instanceof SwipeRecycleViewItemLayout) {

    } else {
        SwipeRecycleViewItemLayout swipeRecycleViewItemLayout = new SwipeRecycleViewItemLayout(mContext);
        itemView.setClickable(true);//防止穿透内容布局, 直接点到了menu上
        swipeRecycleViewItemLayout.addView(itemView);
        swipeRecycleViewItemLayout.setLayoutParams(itemView.getLayoutParams());

        itemView = swipeRecycleViewItemLayout;
    }
    return super.createBaseViewHolder(viewType, itemView);
}
 
Example 11
Project: UltimateRecyclerView   File: SwipeItem.java   View Source Code Vote up 6 votes
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    //令自己可点击,从而获取触摸事件
    setClickable(true);
    //由于ViewHolder的复用机制,每次这里要手动恢复初始值
    mRightMenuWidths = 0;
    mHeight = 0;
    //适配GridLayoutManager,将以第一个子Item(即ContentItem)的宽度为控件宽度
    int contentWidth = 0;
    int childCount = getChildCount();
    //为了子View的高,可以matchParent(参考的FrameLayout 和LinearLayout的Horizontal)
    final boolean measureMatchParentChildren = MeasureSpec.getMode(heightMeasureSpec) != MeasureSpec.EXACTLY;
    boolean isNeedMeasureChildHeight = false;
    for (int i = 0; i < childCount; i++) {
        View childView = getChildAt(i);
        //令每一个子View可点击,从而获取触摸事件
        childView.setClickable(true);
        if (childView.getVisibility() != GONE) {
            //后续计划加入上滑、下滑,则将不再支持Item的margin
            measureChild(childView, widthMeasureSpec, heightMeasureSpec);
            //measureChildWithMargins(childView, widthMeasureSpec, 0, heightMeasureSpec, 0);
            final MarginLayoutParams lp = (MarginLayoutParams) childView.getLayoutParams();
            mHeight = Math.max(mHeight, childView.getMeasuredHeight());
            if (measureMatchParentChildren && lp.height == ViewGroup.LayoutParams.MATCH_PARENT) {
                isNeedMeasureChildHeight = true;
            }
            if (i > 0) {
                //第一个布局是Left item,从第二个开始才是RightMenu
                mRightMenuWidths += childView.getMeasuredWidth();
            } else {
                mContentView = childView;
                contentWidth = childView.getMeasuredWidth();
            }
        }
    }

    //宽度取第一个Item(Content)的宽度
    setMeasuredDimension(getPaddingLeft() + getPaddingRight() + contentWidth,
            mHeight + getPaddingTop() + getPaddingBottom());
    //滑动判断的临界值
    mLimit = mRightMenuWidths * 4 / 10;
    //如果子View的height有MatchParent属性的,设置子View高度
    if (isNeedMeasureChildHeight) {
        forceUniformHeight(childCount, widthMeasureSpec);
    }
}
 
Example 12
Project: RNLearn_Project1   File: LayoutAnimationController.java   View Source Code Vote up 6 votes
/**
 * Disables user interactions for a view and all it's subviews.
 */
private void disableUserInteractions(View view) {
  view.setClickable(false);
  if (view instanceof ViewGroup) {
    ViewGroup viewGroup = (ViewGroup)view;
    for (int i = 0; i < viewGroup.getChildCount(); i++) {
      disableUserInteractions(viewGroup.getChildAt(i));
    }
  }
}
 
Example 13
Project: Hotspot-master-devp   File: AdapterWrapper.java   View Source Code Vote up 6 votes
/**
 * Get a header view. This optionally pulls a header from the supplied
 * {@link WrapperView} and will also recycle the divider if it exists.
 */
private View configureHeader(WrapperView wv, final int position) {
	View header = wv.mHeader == null ? popHeader() : wv.mHeader;
	header = mDelegate.getHeaderView(position, header, wv);
	if (header == null) {
		throw new NullPointerException("Header view must not be null.");
	}
	//if the header isn't clickable, the listselector will be drawn on top of the header
	header.setClickable(true);
	header.setOnClickListener(new OnClickListener() {

		@Override
		public void onClick(View v) {
			if(mOnHeaderClickListener != null){
				long headerId = mDelegate.getHeaderId(position);
				mOnHeaderClickListener.onHeaderClick(v, position, headerId);
			}
		}
	});
	return header;
}
 
Example 14
Project: GitHub   File: DownloadActivity.java   View Source Code Vote up 5 votes
/**
 * 控制 TabLayout 点击使能
 * @param canClick
 */
private void _setTabLayoutCanClick(boolean canClick){
    LinearLayout tabStrip= (LinearLayout) mTabLayout.getChildAt(0);
    for (int i = 0; i < tabStrip.getChildCount(); i++) {
        View tabView = tabStrip.getChildAt(i);
        if(tabView !=null){
            tabView.setClickable(canClick);
        }
    }
}
 
Example 15
Project: RNLearn_Project1   File: LayoutAnimationController.java   View Source Code Vote up 5 votes
/**
 * Disables user interactions for a view and all it's subviews.
 */
private void disableUserInteractions(View view) {
  view.setClickable(false);
  if (view instanceof ViewGroup) {
    ViewGroup viewGroup = (ViewGroup)view;
    for (int i = 0; i < viewGroup.getChildCount(); i++) {
      disableUserInteractions(viewGroup.getChildAt(i));
    }
  }
}
 
Example 16
Project: iosched-reader   File: MyScheduleAdapter.java   View Source Code Vote up 5 votes
private static void clearClickable(View view) {
    view.setOnClickListener(null);
    view.setBackgroundResource(0);
    view.setClickable(false);
}
 
Example 17
Project: GitHub   File: DynamicHelper.java   View Source Code Vote up 5 votes
/**
 * apply clickable in view
 */
public static void applyClickable(View view, DynamicProperty property) {
    if (view != null) {
        switch (property.type) {
            case BOOLEAN: {
                view.setClickable(property.getValueBoolean());
            }
            break;
        }
    }
}
 
Example 18
Project: financisto1-holo   File: TransactionInfoDialog.java   View Source Code Vote up 5 votes
private void add(LinearLayout layout, int labelId, String data, String pictureFileName) {
    Bitmap thumb = ThumbnailUtil.loadThumbnail(pictureFileName);
    View v = inflater.new PictureBuilder(layout)
            .withPicture(context, thumb)
            .withLabel(labelId)
            .withData(data).create();
    v.setClickable(false);
    v.setFocusable(false);
    v.setFocusableInTouchMode(false);
    ImageView pictureView = (ImageView) v.findViewById(R.id.picture);
    pictureView.setTag(pictureFileName);
}
 
Example 19
Project: Android-Gank-Share   File: BaseRecyclerAdapter.java   View Source Code Vote up 5 votes
BaseHolder(View itemView){
    super(itemView);
    view = itemView;
    itemView.setBackgroundResource(R.drawable.touch_bg);
    itemView.setClickable(true);
}
 
Example 20
Project: boohee_v5.6   File: WaterMakerTextFactory.java   View Source Code Vote up 5 votes
public void initView(View v, Map<String, String> mParams) {
    v.setClickable(true);
    String leftText = (String) mParams.get(UP_LEFT_TEXT);
    String midText = (String) mParams.get(UP_MIDDLE_TEXT);
    String rightText = (String) mParams.get(UP_RIGHT_TEXT);
    String botText = (String) mParams.get(BOTTOM_TEXT);
    if (!TextUtils.isEmpty(leftText)) {
        TextView mUpLeftText = (TextView) v.findViewById(R.id.upLeftText);
        mUpLeftText.setText(leftText);
        mUpLeftText.setVisibility(0);
    }
    if (!TextUtils.isEmpty(midText)) {
        TextView mUpMiddleText = (TextView) v.findViewById(R.id.upMiddleText);
        mUpMiddleText.setText(midText);
        mUpMiddleText.setVisibility(0);
    }
    if (!TextUtils.isEmpty(rightText)) {
        TextView mUpRightText = (TextView) v.findViewById(R.id.upRightText);
        mUpRightText.setText(rightText);
        mUpRightText.setVisibility(0);
    }
    if (!TextUtils.isEmpty(botText)) {
        TextView mBottomText = (TextView) v.findViewById(R.id.bottomText);
        mBottomText.setText(botText);
        mBottomText.setVisibility(0);
    }
}