Java Code Examples for android.view.View#setClickable()
The following examples show how to use
android.view.View#setClickable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java From fooXposed with Apache License 2.0 | 6 votes |
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(); }
Example 2
Source File: FloatingActionButton.java From UltimateAndroid with Apache License 2.0 | 6 votes |
/** * 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); }
Example 3
Source File: TurbolinksView.java From turbolinks-android with MIT License | 6 votes |
/** * <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); }
Example 4
Source File: BuildModule.java From DebugDrawer with Apache License 2.0 | 6 votes |
@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; }
Example 5
Source File: TabWidget.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@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)); }
Example 6
Source File: UIUtils.java From v2ex with Apache License 2.0 | 5 votes |
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); } }
Example 7
Source File: MasterFragmentDelegate.java From FragmentMaster with Apache License 2.0 | 5 votes |
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); } }
Example 8
Source File: SubActionButton.java From Bitocle with Apache License 2.0 | 5 votes |
/** * 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); }
Example 9
Source File: AbstractViewPagerActivity.java From iBeebo with GNU General Public License v3.0 | 5 votes |
public void enableView(View view) { if (view != null) { view.setEnabled(true); view.setClickable(true); view.setAlpha(1.0f); } }
Example 10
Source File: PullToRefreshAdapterViewBase.java From handmarkPulltorefreshLibrary with Apache License 2.0 | 5 votes |
/** * 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; }
Example 11
Source File: ViewTouchWrapper.java From XToast with Apache License 2.0 | 5 votes |
ViewTouchWrapper(XToast toast, View view, OnTouchListener listener) { mToast = toast; mListener = listener; view.setFocusable(true); view.setEnabled(true); view.setClickable(true); view.setOnTouchListener(this); }
Example 12
Source File: MainActivity.java From Aria2App with GNU General Public License v3.0 | 5 votes |
@Override public void onMenuExpanded() { final View mask = findViewById(R.id.main_mask); mask.setVisibility(View.VISIBLE); mask.setClickable(true); mask.setOnClickListener(view -> fabMenu.collapse()); }
Example 13
Source File: PullToRefreshAdapterViewBase.java From BigApp_Discuz_Android with Apache License 2.0 | 5 votes |
/** * 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; }
Example 14
Source File: UIUtils.java From RetailStore with Apache License 2.0 | 5 votes |
@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); } }
Example 15
Source File: PullToRefreshAdapterViewBase.java From SwipeMenuAndRefresh with Apache License 2.0 | 5 votes |
/** * 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; }
Example 16
Source File: AnimatingToggle.java From Silence with GNU General Public License v3.0 | 5 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 17
Source File: SuggestionView.java From AndroidChromium with Apache License 2.0 | 4 votes |
/** * 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); }
Example 18
Source File: JobsListAdapter.java From Varis-Android with Apache License 2.0 | 4 votes |
JobViewHolder(View itemView) { super(itemView); ButterKnife.bind(this, itemView); itemView.setClickable(true); mParent.setOnClickListener(this); }
Example 19
Source File: NodeDetailsActivity.java From Android-nRF-Mesh-Library with BSD 3-Clause "New" or "Revised" License | 4 votes |
@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); } }