Example usage for android.view View setClickable

List of usage examples for android.view View setClickable

Introduction

In this page you can find the example usage for android.view View setClickable.

Prototype

public void setClickable(boolean clickable) 

Source Link

Document

Enables or disables click events for this view.

Usage

From source file:com.emilsjolander.components.stickylistheaders.StickyListHeadersCursorAdapter.java

private View attachHeaderToListItem(View header, View listItem) {
    WrapperView wrapper = null;/*from   w  w  w .  jav  a2 s. co m*/
    if (wrapperCache.size() > 0) {
        wrapper = wrapperCache.remove(0);
    }
    if (wrapper == null) {
        wrapper = new WrapperView(context);
    }
    // this does so touches on header are not counted as listitem clicks
    if (header != null) {
        header.setClickable(true);
        header.setFocusable(false);
    }

    return wrapper.wrapViews(listItem, null, header);

}

From source file:com.example.wechatsample.utils.widget.PagerSlidingTabStrip.java

private void addTab(final int position, View tab) {
    tab.setFocusable(true);//  w  w  w .  j av  a2 s .co m
    tab.setClickable(true);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (position != selectedPosition) {
                pager.setCurrentItem(position);
            }
        }
    });

    //      tab.setPadding(tabPadding, 0, tabPadding, 0);
    tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
}

From source file:com.arlib.floatingsearchview.util.view.MenuView.java

/**
 * Hides all the menu items flagged with "ifRoom"
 *
 * @param withAnim/*from   www.j  av  a  2  s  . c  o m*/
 */
public void hideIfRoomItems(boolean withAnim) {

    if (mMenu == -1)
        return;

    mActionShowAlwaysItems.clear();
    cancelChildAnimListAndClear();

    List<MenuItemImpl> showAlwaysActionItems = filter(mMenuItems, new MenuItemImplPredicate() {
        @Override
        public boolean apply(MenuItemImpl menuItem) {
            return menuItem.requiresActionButton();
        }
    });

    int actionItemIndex;
    for (actionItemIndex = 0; actionItemIndex < mActionItems.size()
            && actionItemIndex < showAlwaysActionItems.size(); actionItemIndex++) {

        final MenuItemImpl actionItem = showAlwaysActionItems.get(actionItemIndex);

        if (mActionItems.get(actionItemIndex).getItemId() != showAlwaysActionItems.get(actionItemIndex)
                .getItemId()) {

            ImageView action = (ImageView) getChildAt(actionItemIndex);
            action.setImageDrawable(Util.setIconColor(actionItem.getIcon(), mActionIconColor));

            action.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {

                    if (mMenuCallback != null)
                        mMenuCallback.onMenuItemSelected(mMenuBuilder, actionItem);
                }
            });

        }

        mActionShowAlwaysItems.add(actionItem);
    }

    final int diff = mActionItems.size() - actionItemIndex + (mHasOverflow ? 1 : 0);

    anims = new ArrayList<>();

    for (int i = 0; i < actionItemIndex; i++) {
        final View currentChild = getChildAt(i);
        final float destTransX = ACTION_DIMENSION_PX * diff - (mHasOverflow ? Util.dpToPx(8) : 0);
        anims.add(ViewPropertyObjectAnimator.animate(currentChild)
                .setDuration(withAnim ? HIDE_IF_ROOM_ITEMS_ANIM_DURATION : 0)
                .setInterpolator(new AccelerateInterpolator()).addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {

                        currentChild.setTranslationX(destTransX);
                    }
                }).translationXBy(destTransX).get());
    }

    for (int i = actionItemIndex; i < diff + actionItemIndex; i++) {

        final View currentView = getChildAt(i);

        currentView.setClickable(false);

        if (i != getChildCount() - 1)
            anims.add(ViewPropertyObjectAnimator.animate(currentView)
                    .setDuration(withAnim ? HIDE_IF_ROOM_ITEMS_ANIM_DURATION : 0)
                    .addListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationEnd(Animator animation) {

                            currentView.setTranslationX(ACTION_DIMENSION_PX);
                        }
                    }).translationXBy(ACTION_DIMENSION_PX).get());

        anims.add(ViewPropertyObjectAnimator.animate(currentView)
                .setDuration(withAnim ? HIDE_IF_ROOM_ITEMS_ANIM_DURATION : 0)
                .addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {

                        currentView.setScaleX(0.5f);
                    }
                }).scaleX(.5f).get());
        anims.add(ViewPropertyObjectAnimator.animate(currentView)
                .setDuration(withAnim ? HIDE_IF_ROOM_ITEMS_ANIM_DURATION : 0)
                .addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {

                        currentView.setScaleY(0.5f);
                    }
                }).scaleY(.5f).get());
        anims.add(ViewPropertyObjectAnimator.animate(getChildAt(i))
                .setDuration(withAnim ? HIDE_IF_ROOM_ITEMS_ANIM_DURATION : 0)
                .addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {

                        currentView.setAlpha(0.0f);
                    }
                }).alpha(0.0f).get());
    }

    final int actinItemsCount = actionItemIndex;
    if (!anims.isEmpty()) {

        AnimatorSet animSet = new AnimatorSet();
        if (!withAnim)
            animSet.setDuration(0);
        animSet.playTogether(anims.toArray(new ObjectAnimator[anims.size()]));
        animSet.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {

                if (mOnVisibleWidthChanged != null)
                    mOnVisibleWidthChanged.onVisibleWidthChanged(((int) ACTION_DIMENSION_PX * actinItemsCount));
            }
        });
        animSet.start();
    }

}

From source file:com.apptentive.android.sdk.module.engagement.interaction.fragment.SurveyFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ImageButton infoButton = (ImageButton) view.findViewById(R.id.info);
    infoButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(final View view) {
            // Set info button not clickable when it was first clicked
            view.setClickable(false);
            getActivity().runOnUiThread(new Runnable() {
                @Override/*from  ww w  .  j a va  2 s .co m*/
                public void run() {
                    final Handler handler = new Handler();
                    handler.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            view.setClickable(true);
                        }
                    }, 100);

                }
            });
            ApptentiveInternal.getInstance().showAboutInternal(getActivity(), false);
        }
    });
    scrollView = (ApptentiveNestedScrollView) view.findViewById(R.id.survey_scrollview);
    scrollView.setOnScrollChangeListener(this);

    /* Android's ScrollView (when scrolled or fling'd) by default always set the focus to an EditText when
     * it's one of it's children.
     * The following is needed to change this behavior such that touching outside EditText would take
     * away the focus
     */
    scrollView.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
    scrollView.setFocusable(true);
    scrollView.setFocusableInTouchMode(true);
    scrollView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            v.requestFocusFromTouch();
            Util.hideSoftKeyboard(getContext(), v);
            return false;
        }
    });

    getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

}

From source file:com.example.view.astuetz.PagerSlidingTabStrip.java

private void addTab(final int position, View tab) {
    tab.setFocusable(true);//from  ww  w. java 2 s. c  om
    tab.setClickable(true);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            try {
                pager.setCurrentItem(position);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });

    tab.setPadding(tabPadding, tabPaddingTop, tabPadding, tabPaddingTop);
    tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
    LinearLayout.LayoutParams le = (android.widget.LinearLayout.LayoutParams) tab.getLayoutParams();
    le.weight = 1;
    tab.setLayoutParams(le);
}

From source file:com.xujun.funapp.widget.TabPagerIndicator.java

private void addTab(final int position, View tab) {
    tab.setFocusable(true);//from  w ww. j  av a  2s  .c  o m
    tab.setClickable(true);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pager.setCurrentItem(position);
        }
    });
    if (!isSame) {
        tab.setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding);
        wrapTabLayoutParams.setMargins(0, 0, 0, 0);
        expandedTabLayoutParams.setMargins(0, 0, 0, 0);
    } else {
        wrapTabLayoutParams.setMargins(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding);
        expandedTabLayoutParams.setMargins(horizontalPadding, verticalPadding, horizontalPadding,
                verticalPadding);
    }

    tabsContainer.addView(tab, position, isExpand ? expandedTabLayoutParams : wrapTabLayoutParams);
}

From source file:com.waz.zclient.pages.main.conversation.SingleImageFragment.java

private void fadeView(final View view, final boolean fadeIn) {
    isFading = true;//from www . j a va2  s  .com
    float toAlpha = fadeIn ? 1f : 0f;

    view.setClickable(fadeIn);
    view.animate().alpha(toAlpha).setInterpolator(new Quart.EaseOut())
            .setDuration(getResources().getInteger(R.integer.single_image_message__overlay__fade_duration))
            .withStartAction(new Runnable() {
                @Override
                public void run() {
                    if (fadeIn) {
                        view.setVisibility(View.VISIBLE);
                    }
                }
            }).withEndAction(new Runnable() {
                @Override
                public void run() {
                    if (!fadeIn) {
                        view.setVisibility(View.GONE);
                    }
                    isFading = false;
                }
            }).start();
}

From source file:org.deviceconnect.android.manager.setting.ServiceListActivity.java

/**
 * ???.//  w w w.  ja v a 2  s.c  om
 * @param enable true: ?false: 
 */
private void setGuideClickable(boolean enable) {
    View guideView = findViewById(R.id.activity_service_guide);
    if (guideView != null) {
        guideView.setClickable(enable);
    }

    Button button = findViewById(R.id.activity_service_guide_button);
    if (button != null) {
        button.setEnabled(enable);
    }
}

From source file:com.akop.bach.fragment.xboxlive.MessagesFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (container == null)
        return null;

    View layout = inflater.inflate(R.layout.xbl_fragment_message_list, container, false);

    mAdapter = new MyCursorAdapter(getActivity(), null);

    View composeMessageButton = layout.findViewById(R.id.new_message);
    TextView composeMessageDesc = (TextView) layout.findViewById(R.id.compose_message_description);
    View composeMessageTitle = layout.findViewById(R.id.compose_message_title);

    if (composeMessageButton != null) {
        if (mAccount.canSendMessages()) {
            composeMessageButton.setFocusable(true);
            composeMessageButton.setClickable(true);

            composeMessageTitle.setVisibility(View.VISIBLE);
            composeMessageDesc.setText(R.string.compose_new_message);

            composeMessageButton.setOnClickListener(new OnClickListener() {
                @Override/*from   w  w  w.  jav  a 2 s . co  m*/
                public void onClick(View v) {
                    MessageCompose.actionComposeMessage(getActivity(), mAccount, null);
                }
            });
        } else {
            composeMessageButton.setFocusable(false);
            composeMessageButton.setClickable(false);

            composeMessageTitle.setVisibility(View.GONE);
            composeMessageDesc.setText(R.string.compose_not_available);
        }
    }

    mMessage = (TextView) layout.findViewById(R.id.message);
    mMessage.setText(R.string.message_list_is_empty);

    mListView = (ListView) layout.findViewById(R.id.list);
    mListView.setOnItemClickListener(this);
    mListView.setAdapter(mAdapter);
    mListView.setEmptyView(mMessage);

    registerForContextMenu(mListView);

    mProgress = layout.findViewById(R.id.loading);

    return layout;
}

From source file:uk.ac.horizon.ubihelper.ui.LoggingChannelListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.log_channel_list);
    listView = (ListView) findViewById(R.id.log_channel_list);

    prefs = PreferenceManager.getDefaultSharedPreferences(this);

    final OnCheckedChangeListener enableListener = new OnCheckedChangeListener() {
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            String cn = (String) buttonView.getTag();
            Log.d(TAG, "onCheckedChanged " + cn + " -> " + isChecked);
            // TODO - update preference
            if (isChecked && !isLogChannel(cn))
                enableChannel(cn);/*w ww.jav a2 s  .  c  o m*/
            else if (!isChecked && isLogChannel(cn))
                disableChannel(cn);

        }
    };
    //listAdapter = new ArrayAdapter<String>(this, R.layout.channel_list_item);
    listAdapter = new ArrayAdapter<String>(this, R.layout.log_channel_item, R.id.log_channel_item_name) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View v = convertView;
            if (v == null) {
                v = LoggingChannelListActivity.this.getLayoutInflater().inflate(R.layout.log_channel_item,
                        null);
            }
            String cn = getItem(position);
            CheckBox enabled = (CheckBox) v.findViewById(R.id.log_channel_item_enabled);
            enabled.setTag(cn);
            enabled.setChecked(isLogChannel(cn));
            enabled.setOnCheckedChangeListener(enableListener);
            TextView name = (TextView) v.findViewById(R.id.log_channel_item_name);
            name.setText(cn);
            //TextView description = (TextView)v.findViewById(R.id.peer_item_description);
            //description.setText(pi.trusted ? "Trusted peer" : "Untrusted peer");
            v.setClickable(true);
            v.setTag(cn);
            //v.setOnClickListener(clickListener);
            return v;
        }
    };
    listView.setAdapter(listAdapter);

}