List of usage examples for android.view View setLongClickable
public void setLongClickable(boolean longClickable)
From source file:android.support.v7.widget.TooltipCompatHandler.java
/** * Set the tooltip text for the view.// w ww . j a v a 2s . c om * * @param view view to set the tooltip on * @param tooltipText the tooltip text */ public static void setTooltipText(View view, CharSequence tooltipText) { // The code below is not attempting to update the tooltip text // for a pending or currently active tooltip, because it may lead // to updating the wrong tooltipin in some rare cases (e.g. when // action menu item views are recycled). Instead, the tooltip is // canceled/hidden. This might still be the wrong tooltip, // but hiding wrong tooltip is less disruptive UX. if (sPendingHandler != null && sPendingHandler.mAnchor == view) { setPendingHandler(null); } if (TextUtils.isEmpty(tooltipText)) { if (sActiveHandler != null && sActiveHandler.mAnchor == view) { sActiveHandler.hide(); } view.setOnLongClickListener(null); view.setLongClickable(false); view.setOnHoverListener(null); } else { new TooltipCompatHandler(view, tooltipText); } }
From source file:net.reichholf.dreamdroid.activities.VirtualRemoteActivity.java
/** * Registers an OnClickListener for a specific GUI Element. OnClick the * function <code>onButtonClicked</code> will be called with the given id * // w ww . ja v a2 s . c o m * @param v * The view to register an OnClickListener for * @param id * The item ID to register the listener for */ protected void registerOnClickListener(View v, final int id) { v.setLongClickable(true); v.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { onButtonClicked(id, true); return true; } }); v.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { onButtonClicked(id, false); } }); }
From source file:jahirfiquitiva.iconshowcase.adapters.ChangelogAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { LayoutInflater inflater = LayoutInflater.from(context); convertView = inflater.inflate(R.layout.changelog_content, parent, false); convertView.setClickable(false); convertView.setLongClickable(false); convertView.setFocusable(false); convertView.setFocusableInTouchMode(false); convertView.setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent)); }//from w ww . ja v a 2 s . c om TextView title = (TextView) convertView.findViewById(R.id.changelog_title); TextView content = (TextView) convertView.findViewById(R.id.changelog_content); String nameStr = mChangelog[position][0]; String contentStr = ""; for (int i = 1; i < mChangelog[position].length; i++) { if (i > 1) { // No need for new line on the first item contentStr += "\n"; } contentStr += "\u2022 "; contentStr += mChangelog[position][i]; } title.setText(nameStr); title.setClickable(false); title.setLongClickable(false); title.setFocusable(false); title.setFocusableInTouchMode(false); title.setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent)); content.setText(contentStr); content.setClickable(false); content.setLongClickable(false); content.setFocusable(false); content.setFocusableInTouchMode(false); content.setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent)); return convertView; }
From source file:uk.ac.horizon.artcodes.activity.NavigationActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Feature.get(this, R.bool.feature_show_welcome).isEnabled()) { startActivity(new Intent(this, AboutArtcodesActivity.class)); return;//from w ww . ja va2 s. com } binding = DataBindingUtil.setContentView(this, R.layout.navigation); setSupportActionBar(binding.toolbar); binding.navigation.setNavigationItemSelectedListener(this); final View headerView = binding.navigation.inflateHeaderView(R.layout.navigation_header); final MenuItem featureItem = binding.navigation.getMenu().findItem(R.id.nav_features); if (Feature.get(this, R.bool.feature_edit_features).isEnabled()) { featureItem.setVisible(true); } else { headerView.setLongClickable(true); headerView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { featureItem.setVisible(true); Feature.get(getBaseContext(), R.bool.feature_edit_features).setEnabled(true); return false; } }); } updateAccounts(); drawerToggle = new ActionBarDrawerToggle(this, binding.drawer, binding.toolbar, R.string.open, R.string.close) { @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); updateAccounts(); } }; binding.drawer.addDrawerListener(drawerToggle); drawerToggle.syncState(); int navigationIndex = R.id.nav_home; if (savedInstanceState != null) { navigationIndex = savedInstanceState.getInt(NAV_ITEM_ID, R.id.nav_home); } MenuItem item = binding.navigation.getMenu().findItem(navigationIndex); if (item == null) { item = binding.navigation.getMenu().findItem(R.id.nav_home); } navigate(item, false); final GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(getString(R.string.oauth_client_id)).requestEmail().requestProfile().build(); apiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this, new GoogleApiClient.OnConnectionFailedListener() { @Override public void onConnectionFailed(@NonNull final ConnectionResult connectionResult) { Log.i("Signin", "Failed " + connectionResult); } }).addApi(Auth.GOOGLE_SIGN_IN_API, gso).build(); apiClient.connect(); }
From source file:com.cachirulop.moneybox.fragment.MoneyboxFragment.java
/** * Add the currency buttons dynamically from the money_defs.xml file *//* w w w. j av a2 s.co m*/ private void addButtons() { ArrayList<CurrencyValueDef> currencies; LinearLayout buttons; Activity parent; parent = getActivity(); buttons = (LinearLayout) parent.findViewById(R.id.moneyButtonsLayout); currencies = CurrencyManager.getCurrencyDefList(); View.OnClickListener listener; listener = new View.OnClickListener() { public void onClick(View v) { onMoneyClicked(v); } }; for (CurrencyValueDef c : currencies) { ImageView v; v = new ImageView(parent); v.setOnClickListener(listener); v.setImageDrawable(c.getDrawable()); v.setLongClickable(true); v.setTag(c); buttons.addView(v); } }
From source file:ti.modules.titanium.ui.widget.TiUIScrollView.java
@Override public void processProperties(KrollDict d) { boolean showHorizontalScrollBar = false; boolean showVerticalScrollBar = false; if (d.containsKey(TiC.PROPERTY_SCROLLING_ENABLED)) { setScrollingEnabled(d.get(TiC.PROPERTY_SCROLLING_ENABLED)); }//from ww w . j ava 2 s . c o m if (d.containsKey(TiC.PROPERTY_SHOW_HORIZONTAL_SCROLL_INDICATOR)) { showHorizontalScrollBar = TiConvert.toBoolean(d, TiC.PROPERTY_SHOW_HORIZONTAL_SCROLL_INDICATOR); } if (d.containsKey(TiC.PROPERTY_SHOW_VERTICAL_SCROLL_INDICATOR)) { showVerticalScrollBar = TiConvert.toBoolean(d, TiC.PROPERTY_SHOW_VERTICAL_SCROLL_INDICATOR); } if (showHorizontalScrollBar && showVerticalScrollBar) { Log.w(TAG, "Both scroll bars cannot be shown. Defaulting to vertical shown"); showHorizontalScrollBar = false; } if (d.containsKey(TiC.PROPERTY_CONTENT_OFFSET)) { Object offset = d.get(TiC.PROPERTY_CONTENT_OFFSET); setContentOffset(offset); } int type = TYPE_VERTICAL; boolean deduced = false; if (d.containsKey(TiC.PROPERTY_WIDTH) && d.containsKey(TiC.PROPERTY_CONTENT_WIDTH)) { Object width = d.get(TiC.PROPERTY_WIDTH); Object contentWidth = d.get(TiC.PROPERTY_CONTENT_WIDTH); if (width.equals(contentWidth) || showVerticalScrollBar) { type = TYPE_VERTICAL; deduced = true; } } if (d.containsKey(TiC.PROPERTY_HEIGHT) && d.containsKey(TiC.PROPERTY_CONTENT_HEIGHT)) { Object height = d.get(TiC.PROPERTY_HEIGHT); Object contentHeight = d.get(TiC.PROPERTY_CONTENT_HEIGHT); if (height.equals(contentHeight) || showHorizontalScrollBar) { type = TYPE_HORIZONTAL; deduced = true; } } // android only property if (d.containsKey(TiC.PROPERTY_SCROLL_TYPE)) { Object scrollType = d.get(TiC.PROPERTY_SCROLL_TYPE); if (scrollType.equals(TiC.LAYOUT_VERTICAL)) { type = TYPE_VERTICAL; } else if (scrollType.equals(TiC.LAYOUT_HORIZONTAL)) { type = TYPE_HORIZONTAL; } else { Log.w(TAG, "scrollType value '" + TiConvert.toString(scrollType) + "' is invalid. Only 'vertical' and 'horizontal' are supported."); } } else if (!deduced && type == TYPE_VERTICAL) { Log.w(TAG, "Scroll direction could not be determined based on the provided view properties. Default VERTICAL scroll direction being used. Use the 'scrollType' property to explicitly set the scrolling direction."); } // we create the view here since we now know the potential widget type LayoutArrangement arrangement = LayoutArrangement.DEFAULT; TiScrollViewLayout scrollViewLayout; if (d.containsKey(TiC.PROPERTY_LAYOUT) && d.getString(TiC.PROPERTY_LAYOUT).equals(TiC.LAYOUT_VERTICAL)) { arrangement = LayoutArrangement.VERTICAL; } else if (d.containsKey(TiC.PROPERTY_LAYOUT) && d.getString(TiC.PROPERTY_LAYOUT).equals(TiC.LAYOUT_HORIZONTAL)) { arrangement = LayoutArrangement.HORIZONTAL; } switch (type) { case TYPE_HORIZONTAL: Log.d(TAG, "creating horizontal scroll view", Log.DEBUG_MODE); this.scrollView = new TiHorizontalScrollView(getProxy().getActivity(), arrangement); scrollViewLayout = ((TiHorizontalScrollView) this.scrollView).getLayout(); break; case TYPE_VERTICAL: default: Log.d(TAG, "creating vertical scroll view", Log.DEBUG_MODE); this.scrollView = new TiVerticalScrollView(getProxy().getActivity(), arrangement); scrollViewLayout = ((TiVerticalScrollView) this.scrollView).getLayout(); } if (d.containsKey(TiC.PROPERTY_CAN_CANCEL_EVENTS)) { ((TiScrollViewLayout) scrollViewLayout) .setCanCancelEvents(TiConvert.toBoolean(d, TiC.PROPERTY_CAN_CANCEL_EVENTS)); } boolean autoContentWidth = (scrollViewLayout .getContentProperty(TiC.PROPERTY_CONTENT_WIDTH) == TiScrollViewLayout.AUTO); boolean wrap = !autoContentWidth; if (d.containsKey(TiC.PROPERTY_HORIZONTAL_WRAP) && wrap) { wrap = TiConvert.toBoolean(d, TiC.PROPERTY_HORIZONTAL_WRAP, true); } scrollViewLayout.setEnableHorizontalWrap(wrap); if (d.containsKey(TiC.PROPERTY_OVER_SCROLL_MODE)) { if (Build.VERSION.SDK_INT >= 9) { this.scrollView.setOverScrollMode( TiConvert.toInt(d.get(TiC.PROPERTY_OVER_SCROLL_MODE), View.OVER_SCROLL_ALWAYS)); } } // Set up the swipe refresh layout container which wraps the scroll view. TiSwipeRefreshLayout swipeRefreshLayout = new TiSwipeRefreshLayout(getProxy().getActivity()) { @Override public void setClickable(boolean value) { View view = getLayout(); if (view != null) { view.setClickable(value); } } @Override public void setLongClickable(boolean value) { View view = getLayout(); if (view != null) { view.setLongClickable(value); } } @Override public void setOnClickListener(View.OnClickListener listener) { View view = getLayout(); if (view != null) { view.setOnClickListener(listener); } } @Override public void setOnLongClickListener(View.OnLongClickListener listener) { View view = getLayout(); if (view != null) { view.setOnLongClickListener(listener); } } }; swipeRefreshLayout.setSwipeRefreshEnabled(false); swipeRefreshLayout.addView(this.scrollView); if (d.containsKey(TiC.PROPERTY_REFRESH_CONTROL)) { Object object = d.get(TiC.PROPERTY_REFRESH_CONTROL); if (object instanceof RefreshControlProxy) { ((RefreshControlProxy) object).assignTo(swipeRefreshLayout); } } setNativeView(swipeRefreshLayout); this.scrollView.setHorizontalScrollBarEnabled(showHorizontalScrollBar); this.scrollView.setVerticalScrollBarEnabled(showVerticalScrollBar); super.processProperties(d); }
From source file:com.facebook.litho.MountState.java
/** * Installs the long click listeners that will dispatch the click handler * defined in the component's props. Unconditionally set the clickable * flag on the view.//from ww w. j a v a 2 s . c o m */ private static void setLongClickHandler(EventHandler<LongClickEvent> longClickHandler, View view) { if (longClickHandler != null) { ComponentLongClickListener listener = getComponentLongClickListener(view); if (listener == null) { listener = new ComponentLongClickListener(); setComponentLongClickListener(view, listener); } listener.setEventHandler(longClickHandler); view.setLongClickable(true); } }
From source file:com.bt.download.android.gui.adapters.TransferListAdapter.java
@Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { Transfer item = getGroupItem(groupPosition); if (convertView == null || convertView instanceof TextView) { // convertView could be a dummy view due to an issue with the slide menu layout request order try {/*from ww w . j a v a2 s. c o m*/ convertView = View.inflate(context.get(), R.layout.view_transfer_list_item, null); } catch (Throwable e) { // creating a dummy view to avoid a force close due to a NPE // next time the "if" will try to recover the actual layout convertView = new TextView(context.get()); ((TextView) convertView).setText("Rendering error"); } } try { boolean clickable = item.getItems().size() == 0; convertView.setOnClickListener(clickable ? viewOnClickListener : null); convertView.setOnLongClickListener(clickable ? viewOnLongClickListener : null); convertView.setClickable(clickable); convertView.setLongClickable(clickable); setupGroupIndicator(convertView, isExpanded, item); convertView.setTag(item); populateGroupView(convertView, item); } catch (Throwable e) { Log.e(TAG, "Fatal error getting the group view: " + e.getMessage(), e); } return convertView; }
From source file:net.phase.wallet.Currency.java
@Override public View getView(int position, View convertView, ViewGroup parent) { double exchrate = Currency.getRate(context.getActiveCurrency()); LayoutInflater inflater = LayoutInflater.from(context); View v = inflater.inflate(R.layout.walletlayout, null); v.setLongClickable(true); v.setOnClickListener(context);/*from w ww .ja v a2s.co m*/ v.setTag(position); DecimalFormat df = new DecimalFormat(WalletActivity.decimalString(decimalpoints)); TextView balanceTextView = (TextView) v.findViewById(R.id.walletBalanceText); balanceTextView.setText(df.format(wallets[position].balance / BalanceRetriever.SATOSHIS_PER_BITCOIN)); TextView curTextView = (TextView) v.findViewById(R.id.walletCurText); curTextView.setTextSize(10); if (exchrate != 0) { curTextView.setText( "(" + df.format(wallets[position].balance * exchrate / BalanceRetriever.SATOSHIS_PER_BITCOIN) + context.getActiveCurrency() + ")"); } else { curTextView.setText(""); } balanceTextView.setTextSize(20); balanceTextView.setTextColor(Color.GREEN); TextView nameTextView = (TextView) v.findViewById(R.id.walletNameText); nameTextView.setText(wallets[position].name); nameTextView.setTextColor(Color.BLACK); nameTextView.setTextSize(16); TextView lastUpdatedTextView = (TextView) v.findViewById(R.id.lastUpdatedText); lastUpdatedTextView.setTextColor(Color.GRAY); lastUpdatedTextView.setTextSize(8); lastUpdatedTextView.setText("Last Updated: " + getTimeStampString(wallets[position].lastUpdated)); TextView infoTextView = (TextView) v.findViewById(R.id.infoText); infoTextView.setTextColor(Color.GRAY); infoTextView.setTextSize(8); infoTextView.setText( wallets[position].keys.length + " keys (" + wallets[position].getActiveKeyCount() + " in use)"); TextView txLastUpdatedTextView = (TextView) v.findViewById(R.id.txLastUpdatedText); txLastUpdatedTextView.setTextColor(Color.GRAY); txLastUpdatedTextView.setTextSize(8); TextView txInfoTextView = (TextView) v.findViewById(R.id.txInfoText); txInfoTextView.setTextColor(Color.GRAY); txInfoTextView.setTextSize(8); if (wallets[position].transactions != null && wallets[position].transactions.length > 0) { txLastUpdatedTextView.setText( "Last Transaction: " + getTimeStampString(Transaction.latest(wallets[position].transactions))); txInfoTextView.setText(wallets[position].transactions.length + " transactions (" + Transaction.compressTransactions(wallets[position].transactions).length + " unique)"); } else { txLastUpdatedTextView.setText(""); txInfoTextView.setText(""); } Button button = (Button) v.findViewById(R.id.updateButton); button.setTag(position); button.setOnClickListener(context); return v; }
From source file:org.appcelerator.titanium.view.TiUIView.java
private void doSetClickable(View view, boolean clickable) { if (view == null) { return;//from www . j a va 2 s . c om } if (!clickable) { view.setOnClickListener(null); // This will set clickable to true in the view, so make sure it stays here so the next line turns it off. view.setClickable(false); view.setOnLongClickListener(null); view.setLongClickable(false); } else if (!(view instanceof AdapterView)) { // n.b.: AdapterView throws if click listener set. // n.b.: setting onclicklistener automatically sets clickable to true. setOnClickListener(view); setOnLongClickListener(view); } }