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:com.facebook.litho.MountState.java

private static void unsetFocusable(View view, MountItem mountItem) {
    view.setFocusable(MountItem.isViewFocusable(mountItem.getFlags()));
}

From source file:io.karim.MaterialTabs.java

private void addTab(final int position, CharSequence title, View tabView) {
    TextView textView = (TextView) tabView.findViewById(R.id.mt_tab_title);
    if (textView != null) {
        if (title != null) {
            textView.setText(title);/*from w  ww . j av a2  s. c  o m*/
        }
    }

    tabView.setFocusable(true);
    tabView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (tabSelectedListener != null) {
                tabSelectedListener.onTabSelected(position);
            }

            if (pager.getCurrentItem() != position) {
                View tab = tabsContainer.getChildAt(pager.getCurrentItem());
                notSelected(tab);
                pager.setCurrentItem(position);
            } else if (tabReselectedListener != null) {
                tabReselectedListener.onTabReselected(position);
            }
        }
    });

    tabsContainer.addView(tabView, position, sameWeightTabs ? expandedTabLayoutParams : defaultTabLayoutParams);
}

From source file:net.evendanan.android.thumbremote.ui.RemoteUiActivity.java

/**
 * Set up a navigation button in the UI. Sets the focus to false so that we
 * can capture KEYCODE_DPAD_CENTER./*w w  w .  j a v a  2  s  .  c  o m*/
 * 
 * @param id id of the button in the resource file
 * @param keycode keyCode we should send to Boxee when this button is
 *            pressed
 */
private void setButtonAction(int id, final int keyCode) {
    View button = findViewById(id);
    if (button == null)
        return;
    button.setFocusable(false);
    button.setTag(new Integer(keyCode));
    button.setOnClickListener(this);
}

From source file:com.homechart.app.commont.matertab.MaterialTabs.java

private void addTab(final int position, CharSequence title, View tabView) {
    TextView textView = (TextView) tabView.findViewById(R.id.mt_tab_title);
    if (textView != null) {
        if (title != null) {
            textView.setText(title);/*w ww .ja v a  2 s  . c  om*/
        }
    }

    tabView.setFocusable(true);
    tabView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (pager.getCurrentItem() != position) {
                View tab = tabsContainer.getChildAt(pager.getCurrentItem());
                notSelected(tab);
                pager.setCurrentItem(position);
            } else if (tabReselectedListener != null) {

                tabReselectedListener.onTabReselected(position);
            }

            if (onClickItemListener != null) {//??

                onClickItemListener.onClickItemListener(position);

            }
        }
    });

    tabsContainer.addView(tabView, position, sameWeightTabs ? expandedTabLayoutParams : defaultTabLayoutParams);
}

From source file:com.qingsongchou.library.widget.tab.PagerSlidingTabStrip.java

private void addTab(final int position, CharSequence title, View tabView) {
    TextView textView = (TextView) tabView.findViewById(R.id.psts_tab_title);
    if (textView != null) {
        if (title != null)
            textView.setText(title);/*www.  j  ava2s  .c o m*/
    }

    tabView.setFocusable(true);
    tabView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mPager.getCurrentItem() != position) {
                View tab = mTabsContainer.getChildAt(mPager.getCurrentItem());
                unSelect(tab);
                mPager.setCurrentItem(position);
            } else if (mTabReselectedListener != null) {
                mTabReselectedListener.onTabReselected(position);
            }
        }
    });
    mTabsContainer.addView(tabView, position, mTabLayoutParams);
}

From source file:net.yaly.ViewPagerDoubleIndicator.java

private void addTab(final int position, CharSequence title, View tabView) {
    TextView textView = (TextView) tabView.findViewById(R.id.vpdi_tab_title);
    if (textView != null) {
        if (title != null)
            textView.setText(title);/*from  w  w w  .  j a v a  2s  . co m*/
    }
    tabView.setFocusable(true);
    tabView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mPager.getCurrentItem() != position) {
                View tab = mTabsContainer.getChildAt(mPager.getCurrentItem());
                unSelect(tab);
                mPager.setCurrentItem(position);
            } else if (mTabReselectedListener != null) {
                mTabReselectedListener.onTabReselected(position);
            }
        }
    });

    mTabsContainer.addView(tabView, position, mTabLayoutParams);
}

From source file:org.ligi.gobandroid_hd.ui.GoActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    GoPrefs.init(this); // TODO remove legacy

    setContentView(R.layout.game);/*from w  ww  . ja va 2s.co  m*/

    ButterKnife.inject(this);

    if (!App.isTesting) {
        // if there where stacktraces collected -> give the user the option to send them
        if (!TraceDroidEmailSender.sendStackTraces("ligi@ligi.de", this) && Build.VERSION.SDK_INT < 21) {
            AppRate.with(this).retryPolicy(RetryPolicy.EXPONENTIAL).initialLaunchCount(5).checkAndShow();
        }
    }

    interaction_scope = App.getInteractionScope();
    getSupportActionBar().setHomeButtonEnabled(true);

    AXT.at(this).disableRotation();

    if (getSettings().isWakeLockEnabled()) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }

    if (getGame() == null) { // cannot do anything without a game
        Log.w("finish()ing " + this + " cuz getGame()==null");
        finish();
        return;
    }

    if (sound_man == null) {
        sound_man = new GoSoundManager(this);
    }

    final View customNav = new CustomActionBar(this);

    final FragmentTransaction fragmentTransAction = getSupportFragmentManager().beginTransaction();
    fragmentTransAction.add(R.id.game_extra_container, getGameExtraFragment()).commit();
    getSupportFragmentManager().executePendingTransactions();

    getSupportActionBar().setCustomView(customNav);
    getSupportActionBar().setDisplayShowCustomEnabled(true);
    customNav.setFocusable(false);

    createInfoToast();

    setupBoard();

    game2ui();
}

From source file:com.shome.app.PagerSlidingTabStrip.java

private void addTab(final int position, View tab) {
    if (useToggleTab) {
        tab.setOnClickListener(new OnClickListener() {
            @Override/*from  w ww.j av a  2s. com*/
            public void onClick(View v) {
                pager.setCurrentItem(position);
                ToggleButton tb = (ToggleButton) v;
                toggleTabIfUsingToggleTabProvider(tb);
            }
        });
    } else {
        tab.setFocusable(true);
        tab.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                pager.setCurrentItem(position);
            }
        });
    }

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

From source file:org.schabi.newpipe.VideoItemDetailFragment.java

private void initSimilarVideos(final StreamInfo info, VideoInfoItemViewCreator videoItemViewCreator) {
    LinearLayout similarLayout = (LinearLayout) activity.findViewById(R.id.similarVideosView);
    ArrayList<StreamPreviewInfo> similar = new ArrayList<>(info.related_videos);
    for (final StreamPreviewInfo item : similar) {
        View similarView = videoItemViewCreator.getViewFromVideoInfoItem(null, similarLayout, item);

        similarView.setClickable(true);/*from w  w  w  . ja v  a 2 s.c o m*/
        similarView.setFocusable(true);
        int[] attrs = new int[] { R.attr.selectableItemBackground };
        TypedArray typedArray = activity.obtainStyledAttributes(attrs);
        int backgroundResource = typedArray.getResourceId(0, 0);
        similarView.setBackgroundResource(backgroundResource);
        typedArray.recycle();

        similarView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_UP) {
                    Intent detailIntent = new Intent(activity, VideoItemDetailActivity.class);
                    detailIntent.putExtra(VideoItemDetailFragment.VIDEO_URL, item.webpage_url);
                    detailIntent.putExtra(VideoItemDetailFragment.STREAMING_SERVICE, streamingServiceId);
                    startActivity(detailIntent);
                    return true;
                }
                return false;
            }
        });

        similarLayout.addView(similarView);
        ImageView rthumb = (ImageView) similarView.findViewById(R.id.itemThumbnailView);
        imageLoader.displayImage(item.thumbnail_url, rthumb, displayImageOptions,
                new ThumbnailLoadingListener());
    }
}

From source file:com.facebook.litho.MountState.java

private static void setFocusable(View view, @NodeInfo.FocusState short focusState) {
    if (focusState == NodeInfo.FOCUS_SET_TRUE) {
        view.setFocusable(true);
    } else if (focusState == NodeInfo.FOCUS_SET_FALSE) {
        view.setFocusable(false);/*  w  w w .j a v  a 2 s.  c  o  m*/
    }
}