android.view.View#setClickable ( )源码实例Demo

下面列出了android.view.View#setClickable ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: DebugDrawer   文件: BuildModule.java
@NonNull
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {

    if (context == null) {
        context = new WeakReference<>(parent.getContext());
    }

    final View view = inflater.inflate(R.layout.dd_debug_drawer_module_build, parent, false);
    view.setClickable(false);
    view.setEnabled(false);

    codeLabel = view.findViewById(R.id.dd_debug_build_code);
    nameLabel = view.findViewById(R.id.dd_debug_build_name);
    packageLabel = view.findViewById(R.id.dd_debug_build_package);

    refresh();

    return view;
}
 
源代码2 项目: android_9.0.0_r45   文件: TabWidget.java
@Override
public void addView(View child) {
    if (child.getLayoutParams() == null) {
        final LinearLayout.LayoutParams lp = new LayoutParams(
                0, ViewGroup.LayoutParams.MATCH_PARENT, 1.0f);
        lp.setMargins(0, 0, 0, 0);
        child.setLayoutParams(lp);
    }

    // Ensure you can navigate to the tab with the keyboard, and you can touch it
    child.setFocusable(true);
    child.setClickable(true);

    if (child.getPointerIcon() == null) {
        child.setPointerIcon(PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_HAND));
    }

    super.addView(child);

    // TODO: detect this via geometry with a tabwidget listener rather
    // than potentially interfere with the view's listener
    child.setOnClickListener(new TabClickListener(getTabCount() - 1));
}
 
源代码3 项目: turbolinks-android   文件: TurbolinksView.java
/**
 * <p>Shows a progress view or a generated screenshot of the webview content (if available)
 * on top of the webview. When advancing to a new url, this indicates that the page is still
 * loading. When resuming an activity in the navigation stack, a screenshot is displayed while the
 * webview is restoring its snapshot.</p>
 * <p>Progress indicator is set to a specified delay before displaying -- a very short delay
 * (like 500 ms) can improve perceived loading time to the user.</p>
 *
 * @param progressView      The progressView to display on top of TurbolinksView.
 * @param progressIndicator The progressIndicator to display in the view.
 * @param delay             The delay before showing the progressIndicator in the view. The default progress view
 *                          is 500 ms.
 */
void showProgress(final View progressView, final View progressIndicator, int delay) {
    TurbolinksLog.d("showProgress called");

    // Don't show the progress view if a screenshot is available
    if (screenshotView != null && screenshotOrientation == getOrientation()) return;

    hideProgress();

    this.progressView = progressView;
    progressView.setClickable(true);
    addView(progressView);

    progressIndicator.setVisibility(View.GONE);

    final Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            progressIndicator.setVisibility(View.VISIBLE);
        }
    }, delay);
}
 
源代码4 项目: UltimateAndroid   文件: FloatingActionButton.java
/**
 * Sets a content view that will be displayed inside this FloatingActionButton.
 * @param contentView
 */
public void setContentView(View contentView, FrameLayout.LayoutParams contentParams) {
    this.contentView = contentView;
    FrameLayout.LayoutParams params;
    if(contentParams == null ){
        params =new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER);
        final int margin = getResources().getDimensionPixelSize(R.dimen.action_button_content_margin);
        params.setMargins(margin, margin, margin, margin);
    }
    else {
        params = contentParams;
    }
    params.gravity = Gravity.CENTER;

    contentView.setClickable(false);
    this.addView(contentView, params);
}
 
源代码5 项目: litho   文件: MountItemTest.java
@Test
public void testUpdateDoesntChangeFlags() {
  LayoutOutput output =
      new LayoutOutput(mNodeInfo, null, mComponent, new Rect(0, 0, 0, 0), 0, 0, 0, 0, 0, 0, null);
  RenderTreeNode node = LayoutOutput.create(output, null, null, null);

  View view = new View(getApplicationContext());

  final MountItem mountItem = new MountItem(node, mComponentHost, view);
  mountItem.setMountData(new LithoMountData(view));

  assertThat(isViewClickable(getMountData(mountItem).getDefaultAttributeValuesFlags())).isFalse();

  view.setClickable(true);

  mountItem.update(node);
  assertThat(isViewClickable(getMountData(mountItem).getDefaultAttributeValuesFlags())).isFalse();
}
 
源代码6 项目: fooXposed   文件: MainActivity.java
public void decryptText(View view) {
    String name = "Foox_4th_01.apk";
    File file = new File(getFilesDir(), name);
    if (copyAssetFile(name, file)) {
        String dexPath = file.getPath();
        String optimizedDirectory = file.getParent();
        ClassLoader parent = getClass().getClassLoader();
        DexClassLoader classLoader = new DexClassLoader(dexPath, optimizedDirectory, null, parent);
        try {
            Class<?> clazz = classLoader.loadClass("foo.ree.demos.x4th01.Base64Util");
            Method method = clazz.getDeclaredMethod("decrypt", String.class);
            String text = (String) method.invoke(clazz, textView.getText().toString());

            if (!TextUtils.isEmpty(text)) {
                textView.setText(text);
                textView.refreshDrawableState();
                view.setClickable(false);
                Toast.makeText(this, "解密成功", Toast.LENGTH_SHORT).show();
                return;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    Toast.makeText(this, "解密失败", Toast.LENGTH_SHORT).show();
}
 
/**
 * 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;
}
 
源代码8 项目: Silence   文件: AnimatingToggle.java
@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);
}
 
/**
 * Sets the Empty View to be used by the Adapter View.
 * We need it handle it ourselves so that we can Pull-to-Refresh when the
 * Empty View is shown.
 * 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.
 * 
 */
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;
}
 
源代码10 项目: RetailStore   文件: UIUtils.java
@SuppressLint("NewApi")
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);
    }
}
 
/**
 * 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;
}
 
源代码12 项目: Aria2App   文件: MainActivity.java
@Override
public void onMenuExpanded() {
    final View mask = findViewById(R.id.main_mask);
    mask.setVisibility(View.VISIBLE);
    mask.setClickable(true);
    mask.setOnClickListener(view -> fabMenu.collapse());
}
 
源代码13 项目: XToast   文件: ViewTouchWrapper.java
ViewTouchWrapper(XToast toast, View view, OnTouchListener listener) {
    mToast = toast;
    mListener = listener;

    view.setFocusable(true);
    view.setEnabled(true);
    view.setClickable(true);
    view.setOnTouchListener(this);
}
 
源代码14 项目: v2ex   文件: UIUtils.java
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);
    }
}
 
源代码15 项目: iBeebo   文件: AbstractViewPagerActivity.java
public void enableView(View view) {
    if (view != null) {
        view.setEnabled(true);
        view.setClickable(true);
        view.setAlpha(1.0f);
    }
}
 
源代码16 项目: Bitocle   文件: SubActionButton.java
/**
 * Sets a content view with custom LayoutParams that will be displayed inside this SubActionButton.
 * @param contentView
 * @param params
 */
public void setContentView(View contentView, FrameLayout.LayoutParams params) {
    if(params == null) {
        params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER);
        final int margin = getResources().getDimensionPixelSize(R.dimen.sub_action_button_content_margin);
        params.setMargins(margin, margin, margin, margin);
    }

    contentView.setClickable(false);
    this.addView(contentView, params);
}
 
源代码17 项目: FragmentMaster   文件: MasterFragmentDelegate.java
public void onViewCreated(View view, Bundle savedInstanceState) {
    // Use window background as the top level background.
    // Note: The view is an instance of NoSaveStateFrameLayout,
    // which is inserted between the Fragment's view and its container by FragmentManager.
    TypedValue outValue = new TypedValue();
    getFragmentContext().getTheme().resolveAttribute(android.R.attr.windowBackground, outValue, true);
    view.setBackgroundResource(outValue.resourceId);
    // Set the "clickable" of the fragment's root view to true to avoid
    // touch events to be passed to the views behind the fragment.
    view.setClickable(true);
    if (getFragmentMaster() != null) {
        getFragmentMaster().dispatchFragmentViewCreated(mMasterFragment);
    }
}
 
源代码18 项目: AndroidChromium   文件: SuggestionView.java
/**
 * Constructs a new omnibox suggestion view.
 *
 * @param context The context used to construct the suggestion view.
 * @param locationBar The location bar showing these suggestions.
 */
public SuggestionView(Context context, LocationBar locationBar) {
    super(context);
    mLocationBar = locationBar;

    mSuggestionHeight =
            context.getResources().getDimensionPixelOffset(R.dimen.omnibox_suggestion_height);
    mSuggestionAnswerHeight =
            context.getResources().getDimensionPixelOffset(
                    R.dimen.omnibox_suggestion_answer_height);

    TypedArray a = getContext().obtainStyledAttributes(
            new int [] {R.attr.selectableItemBackground});
    Drawable itemBackground = a.getDrawable(0);
    a.recycle();

    mContentsView = new SuggestionContentsContainer(context, itemBackground);
    addView(mContentsView);

    mRefineView = new View(context) {
        @Override
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);

            if (mRefineIcon == null) return;
            canvas.save();
            canvas.translate(
                    (getMeasuredWidth() - mRefineIcon.getIntrinsicWidth()) / 2f,
                    (getMeasuredHeight() - mRefineIcon.getIntrinsicHeight()) / 2f);
            mRefineIcon.draw(canvas);
            canvas.restore();
        }

        @Override
        public void setVisibility(int visibility) {
            super.setVisibility(visibility);

            if (visibility == VISIBLE) {
                setClickable(true);
                setFocusable(true);
            } else {
                setClickable(false);
                setFocusable(false);
            }
        }

        @Override
        protected void drawableStateChanged() {
            super.drawableStateChanged();

            if (mRefineIcon != null && mRefineIcon.isStateful()) {
                mRefineIcon.setState(getDrawableState());
            }
        }
    };
    mRefineView.setContentDescription(getContext().getString(
            R.string.accessibility_omnibox_btn_refine));

    // Although this has the same background as the suggestion view, it can not be shared as
    // it will result in the state of the drawable being shared and always showing up in the
    // refine view.
    mRefineView.setBackground(itemBackground.getConstantState().newDrawable());
    mRefineView.setId(R.id.refine_view_id);
    mRefineView.setClickable(true);
    mRefineView.setFocusable(true);
    mRefineView.setLayoutParams(new LayoutParams(0, 0));
    addView(mRefineView);

    mRefineWidth = getResources()
            .getDimensionPixelSize(R.dimen.omnibox_suggestion_refine_width);

    mUrlBar = (UrlBar) locationBar.getContainerView().findViewById(R.id.url_bar);

    mPhoneUrlBarLeftOffsetPx = getResources().getDimensionPixelOffset(
            R.dimen.omnibox_suggestion_phone_url_bar_left_offset);
    mPhoneUrlBarLeftOffsetRtlPx = getResources().getDimensionPixelOffset(
            R.dimen.omnibox_suggestion_phone_url_bar_left_offset_rtl);
}
 
源代码19 项目: Varis-Android   文件: JobsListAdapter.java
JobViewHolder(View itemView) {
    super(itemView);
    ButterKnife.bind(this, itemView);
    itemView.setClickable(true);
    mParent.setOnClickListener(this);
}
 
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_node_details);
    ButterKnife.bind(this);

    final NodeDetailsViewModel viewModel = new ViewModelProvider(this, mViewModelFactory).get(NodeDetailsViewModel.class);
    if (viewModel.getSelectedMeshNode().getValue() == null) {
        finish();
    }

    final ProvisionedMeshNode node = viewModel.getSelectedMeshNode().getValue();
    final ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);

    final Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle(node.getNodeName());

    final View containerProvisioningTimeStamp = findViewById(R.id.container_timestamp);
    containerProvisioningTimeStamp.setClickable(false);
    final TextView timestamp = containerProvisioningTimeStamp.findViewById(R.id.text);
    final String format = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(node.getTimeStamp());
    timestamp.setText(format);

    final View containerUnicastAddress = findViewById(R.id.container_supported_algorithm);
    containerUnicastAddress.setClickable(false);
    final TextView unicastAddress = containerUnicastAddress.findViewById(R.id.text);
    unicastAddress.setText(MeshParserUtils.bytesToHex(MeshAddress.addressIntToBytes(node.getUnicastAddress()), false));

    final View containerDeviceKey = findViewById(R.id.container_device_key);
    containerDeviceKey.setClickable(false);
    final TextView deviceKey = containerDeviceKey.findViewById(R.id.text);
    deviceKey.setText(MeshParserUtils.bytesToHex(node.getDeviceKey(), false));

    final View copyDeviceKey = findViewById(R.id.copy);
    copyDeviceKey.setOnClickListener(v -> {
        if (clipboard != null) {
            final ClipData clipDeviceKey = ClipData.newPlainText("Device Key", MeshParserUtils.bytesToHex(node.getDeviceKey(), false));
            clipboard.setPrimaryClip(clipDeviceKey);
            Toast.makeText(NodeDetailsActivity.this, R.string.device_key_clipboard_copied, Toast.LENGTH_SHORT).show();
        }
    });

    final View containerCompanyIdentifier = findViewById(R.id.container_company_identifier);
    containerCompanyIdentifier.setClickable(false);
    final TextView companyIdentifier = containerCompanyIdentifier.findViewById(R.id.text);
    if (node.getCompanyIdentifier() != null) {
        companyIdentifier.setText(CompanyIdentifiers.getCompanyName(node.getCompanyIdentifier().shortValue()));
    } else {
        companyIdentifier.setText(R.string.unknown);
    }

    final View containerProductIdentifier = findViewById(R.id.container_product_identifier);
    containerProductIdentifier.setClickable(false);
    final TextView productIdentifier = containerProductIdentifier.findViewById(R.id.text);
    if (node.getProductIdentifier() != null) {
        productIdentifier.setText(CompositionDataParser.formatProductIdentifier(node.getProductIdentifier().shortValue(), false));
    } else {
        productIdentifier.setText(R.string.unavailable);
    }

    final View containerProductVersion = findViewById(R.id.container_product_version);
    containerProductVersion.setClickable(false);
    final TextView productVersion = containerProductVersion.findViewById(R.id.text);
    if (node.getVersionIdentifier() != null) {
        productVersion.setText(CompositionDataParser.formatVersionIdentifier(node.getVersionIdentifier().shortValue(), false));
    } else {
        productVersion.setText(R.string.unavailable);
    }

    final View containerCrpl = findViewById(R.id.container_crpl);
    containerCrpl.setClickable(false);
    final TextView crpl = containerCrpl.findViewById(R.id.text);
    if (node.getCrpl() != null) {
        crpl.setText(CompositionDataParser.formatReplayProtectionCount(node.getCrpl().shortValue(), false));
    } else {
        crpl.setText(R.string.unavailable);
    }

    final View containerFeatures = findViewById(R.id.container_features);
    containerFeatures.setClickable(false);
    final TextView features = containerFeatures.findViewById(R.id.text);
    if (node.getNodeFeatures() != null) {
        features.setText(parseFeatures(node.getNodeFeatures()));
    } else {
        features.setText(R.string.unavailable);
    }
}
 
 方法所在类
 同类方法