Example usage for android.view View setFocusable

List of usage examples for android.view View setFocusable

Introduction

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

Prototype

public void setFocusable(@Focusable int focusable) 

Source Link

Document

Sets whether this view can receive focus.

Usage

From source file:org.alfresco.mobile.android.application.fragments.preferences.PasscodePreferences.java

private void disableEnableControls(boolean enable, ViewGroup vg) {
    for (int i = 0; i < vg.getChildCount(); i++) {
        View child = vg.getChildAt(i);
        child.setEnabled(enable);/*from ww w. j  ava 2  s. co  m*/
        child.setFocusable(enable);
        if (child instanceof ViewGroup) {
            disableEnableControls(enable, (ViewGroup) child);
        }
    }
    vg.setEnabled(enable);
    vg.setFocusable(enable);
}

From source file:com.github.johnpersano.supertoasts.demo.views.TabStrip.java

private void addTab(final int position, View tab) {
    tab.setFocusable(true);
    tab.setOnClickListener(new OnClickListener() {
        @Override/*from  w  w w  .j a v  a2 s . co  m*/
        public void onClick(View v) {
            pager.setCurrentItem(position);
        }
    });

    tab.setPadding(tabPadding, 0, tabPadding, 0);

    tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
}

From source file:com.suning.mobile.ebuy.lottery.utils.view.ScrollingTabsView.java

/**
 * Initialize and add all tabs to the layout
 *//*from  w w  w  .  jav  a  2s  .  com*/
private void initTabs() {

    mContainer.removeAllViews();
    mTabs.clear();

    if (mAdapter == null) {
        return;
    }

    for (int i = 0; i < mAdapter.getCount(); i++) {

        final int index = i;

        View tab = mAdapter.getView(i);
        mContainer.addView(tab);
        tab.setFocusable(true);
        mTabs.add(tab);

        if (i != mAdapter.getCount() - 1) {
            mContainer.addView(getSeparator());
        }
        if (isFocusable) {
            tab.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (mClickListener != null) {
                        mClickListener.onClick(index);
                    }
                    if (mPager.getCurrentItem() == index) {
                        selectTab(index);
                    } else {
                        mPager.setCurrentItem(index);
                    }
                }
            });
        }

    }

    selectTab(tabIndex);
}

From source file:cn.org.eshow.framwork.view.sliding.AbSlidingPageView.java

/**
 * ??View?.//from w  w w.j ava2s  .c  o m
 *
 * @param changed the changed
 * @param l the l
 * @param t the t
 * @param r the r
 * @param b the b
 */
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    //?      
    for (int i = 0; i < getChildCount(); i++) {
        View child = getChildAt(i);
        int height = child.getMeasuredHeight();
        int width = child.getMeasuredWidth();
        child.setFocusable(true);
        if (D)
            Log.d(TAG, "--onLayout--:" + width);
        if (i == 0) {
            child.layout(-nextViewOffset, 0, nextViewOffset + width, height);
        } else {
            child.layout(width - nextViewOffset, 0, 2 * width - nextViewOffset, height);
        }
    }

}

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 w  w.  j a va  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:com.wunding.mlplayer.ui.PagerSlidingTabStrip.java

private void addTab(final int position, View tab) {
    tab.setFocusable(true);
    tab.setOnClickListener(new OnClickListener() {
        @Override/*  w  w w . ja  v a2  s .  co  m*/
        public void onClick(View v) {
            pager.setCurrentItem(position);
        }
    });

    tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
}

From source file:nit.contact.views.PagerSlidingTabStrip.java

private void addTab(final int position, View tab) {
    tab.setFocusable(true);
    tab.setOnClickListener(new OnClickListener() {
        @Override/*from  www  .j av  a 2  s  .com*/
        public void onClick(View v) {
            if (mPager.getAdapter() instanceof IconTabProvider) {
                ((IconTabProvider) mPager.getAdapter()).onTabClick(position,
                        mPager.getCurrentItem() == position);
            }
            mPager.setCurrentItem(position);
        }
    });

    tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
}

From source file:com.muzima.view.forms.FormWebViewActivity.java

private View.OnTouchListener createCompleteFormListenerToDisableInput() {
    return new View.OnTouchListener() {
        @Override/* www .  ja  va2s .  c om*/
        public boolean onTouch(View view, MotionEvent motionEvent) {
            if (motionEvent.getAction() != MotionEvent.ACTION_MOVE) {
                view.setFocusable(false);
                view.setEnabled(false);
                return true;
            }
            return false;
        }
    };
}

From source file:com.github.chilinh.android.form.Form.java

public void buildToFragment(Fragment fragment, final Callback.Submit<Fragment> submitCb) {
    View view = fragment.getView();
    FragmentManager fm = fragment.getActivity().getSupportFragmentManager();
    FormModelFragment model = (FormModelFragment) fm.findFragmentByTag(FORM_FRAGMENT_MODEL);
    if (model == null) {
        model = new FormModelFragment();
        fm.beginTransaction().add(model, FORM_FRAGMENT_MODEL).commit();
    }/*from   ww  w.j a  va 2 s  . c  o  m*/
    mModel = model;

    if (TextUtils.isEmpty(mSubmitBtn)) {
        mSubmitBtn = "Summit";
    }

    ViewGroup group = (ViewGroup) view.findViewById(R.id.form_elements_container);
    makeFormView(group);

    View submitBtn = view.findViewById(R.id.button_form_submit);
    if (submitBtn != null) {
        submitBtn.setClickable(true);
        submitBtn.setFocusable(true);

        submitBtn.setOnClickListener((v) -> {
            if (validate(mContext)) {
                if (submitCb != null) {
                    if (submitCb.validate(fragment, Form.this)) {
                        submitCb.onSubmit(fragment, Form.this);
                    }
                    return;
                }
            }
        });
    }
}

From source file:com.justsmartapps.myvault.view.PagerSlidingTabStrip.java

private void addTab(final int position, View tab) {
    tab.setFocusable(true);
    tab.setOnClickListener(new OnClickListener() {
        @Override/*from w ww.  j a  va 2 s . com*/
        public void onClick(View v) {
            pager.setCurrentItem(position);
        }
    });
    tab.setPadding(tabPadding, 0, tabPadding, 0);
    android.widget.LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(0,
            LinearLayout.LayoutParams.MATCH_PARENT);
    layoutParams.weight = 0.5f;
    tab.setLayoutParams(layoutParams);
    tabsContainer.addView(tab, layoutParams);
}