本文整理汇总了Java中android.view.View.setClickable方法的典型用法代码示例。如果您正苦于以下问题:Java View.setClickable方法的具体用法?Java View.setClickable怎么用?Java View.setClickable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.setClickable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBindViewHolder
import android.view.View; //导入方法依赖的package包/类
@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);
}
});
}
}
示例2: MyViewHolder
import android.view.View; //导入方法依赖的package包/类
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);
}
示例3: onActivityCreated
import android.view.View; //导入方法依赖的package包/类
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;
}
}
示例4: onBindView
import android.view.View; //导入方法依赖的package包/类
@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);
}
}
});
}
示例5: repopulateItems
import android.view.View; //导入方法依赖的package包/类
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();
}
示例6: addView
import android.view.View; //导入方法依赖的package包/类
@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);
}
示例7: ViewHolder
import android.view.View; //导入方法依赖的package包/类
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);
}
示例8: onChildAttachedToWindow
import android.view.View; //导入方法依赖的package包/类
@Override
public void onChildAttachedToWindow(View child) {
super.onChildAttachedToWindow(child);
if (!ViewCompat.hasOnClickListeners(child)) {
child.setClickable(true);
child.setOnClickListener(mOnItemOperateListenerInternalInternal);
}
child.setOnLongClickListener(mOnItemOperateListenerInternalInternal);
}
示例9: createBaseViewHolder
import android.view.View; //导入方法依赖的package包/类
@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);
}
示例10: onMeasure
import android.view.View; //导入方法依赖的package包/类
@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);
}
}
示例11: disableUserInteractions
import android.view.View; //导入方法依赖的package包/类
/**
* 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));
}
}
}
示例12: configureHeader
import android.view.View; //导入方法依赖的package包/类
/**
* 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;
}
示例13: _setTabLayoutCanClick
import android.view.View; //导入方法依赖的package包/类
/**
* 控制 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);
}
}
}
示例14: clearClickable
import android.view.View; //导入方法依赖的package包/类
private static void clearClickable(View view) {
view.setOnClickListener(null);
view.setBackgroundResource(0);
view.setClickable(false);
}
示例15: applyClickable
import android.view.View; //导入方法依赖的package包/类
/**
* 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;
}
}
}