Example usage for android.view ViewGroup FOCUS_BLOCK_DESCENDANTS

List of usage examples for android.view ViewGroup FOCUS_BLOCK_DESCENDANTS

Introduction

In this page you can find the example usage for android.view ViewGroup FOCUS_BLOCK_DESCENDANTS.

Prototype

int FOCUS_BLOCK_DESCENDANTS

To view the source code for android.view ViewGroup FOCUS_BLOCK_DESCENDANTS.

Click Source Link

Document

This view will block any of its descendants from getting focus, even if they are focusable.

Usage

From source file:org.opensilk.fuzzyclock.FuzzySettingsPrefsPage.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fuzzy_settings_prefs_page, container, false);
    mPicker = (NumberPicker) v.findViewById(R.id.numberPicker);
    mPicker.setOnValueChangedListener(this);
    mPicker.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
    mColorButton = (Button) v.findViewById(R.id.button_color);
    mColorButton.setOnClickListener(this);
    mFontStyle = (Button) v.findViewById(R.id.button_font);
    mFontStyle.setOnClickListener(this);
    return v;//from ww w .  j a va 2  s  .  co m
}

From source file:co.uk.alt236.restclient4android.adapters.RequestTabsAdapter.java

@Override
public void onPageSelected(int position) {
    TabWidget widget = mTabHost.getTabWidget();
    int oldFocusability = widget.getDescendantFocusability();
    widget.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
    mTabHost.setCurrentTab(position);//w w  w  . j  a v  a  2 s. co m
    widget.setDescendantFocusability(oldFocusability);
}

From source file:com.momock.outlet.tab.PagerTabOutlet.java

public void attach(TabHolder target) {
    Logger.check(target != null, "Parameter target cannot be null!");
    Logger.check(target.getTabContent() instanceof ViewPager,
            "The PagerTabOutlet must contains a ViewPager content!");
    this.target = target;
    final TabHost tabHost = target.getTabHost();
    final ViewPager tabContent = (ViewPager) target.getTabContent();
    plugs = getPlugs();/*from   w w  w.j  ava  2  s  . com*/

    ViewPager pager = (ViewPager) target.getTabContent();
    for (int i = 0; i < plugs.getItemCount(); i++) {
        ITabPlug plug = (ITabPlug) plugs.getItem(i);
        Logger.check(plug.getContent() instanceof ViewHolder,
                "The plug of PagerTabOutlet must include a ViewHolder!");
        ((ViewHolder) plug.getContent()).reset();
    }
    pager.setAdapter(new PagerAdapter() {

        @Override
        public int getCount() {
            return plugs.getItemCount();
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view == object;
        }

        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            ITabPlug plug = (ITabPlug) plugs.getItem(position);
            View view = ((ViewHolder) plug.getContent()).getView();
            container.addView(view);
            return view;
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
            container.removeView((View) object);
        }
    });

    tabContent.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            TabWidget widget = tabHost.getTabWidget();
            int oldFocusability = widget.getDescendantFocusability();
            widget.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
            tabHost.setCurrentTab(position);
            widget.setDescendantFocusability(oldFocusability);
        }

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });
    tabHost.setup();
    tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {

        @Override
        public void onTabChanged(String tabId) {
            int index = tabHost.getCurrentTab();
            ITabPlug plug = (ITabPlug) plugs.getItem(index);
            setActivePlug(plug);
            tabContent.setCurrentItem(index, true);
        }
    });
    for (int i = 0; i < plugs.getItemCount(); i++) {
        final ITabPlug plug = (ITabPlug) plugs.getItem(i);
        Logger.check(plug.getContent() instanceof ViewHolder,
                "Plug in PagerTabOutlet must contains a ViewHolder content!");

        TabHost.TabSpec spec = tabHost.newTabSpec("" + i);
        target.setTabIndicator(spec, plug);
        spec.setContent(new TabContentFactory() {

            @Override
            public View createTabContent(String tag) {
                View v = new View(tabHost.getContext());
                v.setMinimumWidth(0);
                v.setMinimumHeight(0);
                return v;
            }

        });
        tabHost.addTab(spec);
        if (getActivePlug() == plug)
            tabHost.setCurrentTab(i);
    }
}

From source file:com.androidfactorem.visualcv.ui.adapter.FragmentTabAdapter.java

@Override
public void onPageSelected(int position) {
    // Unfortunately when TabHost changes the current tab, it kindly
    // also takes care of putting focus on it when not in touch mode.
    // The jerk./*from   w w  w  .  j a va  2s . c  o  m*/
    // This hack tries to prevent this from pulling focus out of our
    // ViewPager.
    TabWidget widget = mTabHost.getTabWidget();
    int oldFocusability = widget.getDescendantFocusability();
    widget.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
    mTabHost.setCurrentTab(position);
    widget.setDescendantFocusability(oldFocusability);
}

From source file:com.android.firewall.ui.adapter.MainPagerAdapter.java

public void onPageSelected(int position) {
    TabWidget widget = tabHost.getTabWidget();

    int oldFocus = widget.getDescendantFocusability();
    widget.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);

    tabHost.setCurrentTab(position);//from   w w  w .  ja  va 2 s.  com

    widget.setDescendantFocusability(oldFocus);
}

From source file:g7.bluesky.launcher3.AppsCustomizeTabHost.java

/**
 * Disable focus on anything under this view in the hierarchy if we are not visible.
 *///w ww  . j  a  va  2 s . c o m
@Override
public int getDescendantFocusability() {
    if (getVisibility() != View.VISIBLE) {
        return ViewGroup.FOCUS_BLOCK_DESCENDANTS;
    }
    return super.getDescendantFocusability();
}

From source file:com.yojiokisoft.yumekanow.adapter.MainPagerAdapter.java

/**
 * @see ViewPager.OnPageChangeListener#onPageSelected(int)
 *//*from   www .  ja  v a  2 s .c o m*/
@Override
public void onPageSelected(int position) {
    TabWidget widget = mTabHost.getTabWidget();

    int oldFocus = widget.getDescendantFocusability();
    widget.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);

    mTabHost.setCurrentTab(position);

    widget.setDescendantFocusability(oldFocus);
}

From source file:br.com.cybereagle.androidlibrary.ui.adapter.TabsAdapter.java

@Override
public void onPageSelected(int position) {
    // Unfortunately when TabHost changes the current tab, it kindly
    // also takes care of putting focus on it when not in touch mode.
    // The jerk.//from   w ww  .j  av a 2s . co  m
    // This hack tries to prevent this from pulling focus out of our
    // ViewPager.
    TabWidget widget = tabHost.getTabWidget();
    int oldFocusability = widget.getDescendantFocusability();
    widget.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
    tabHost.setCurrentTab(position);
    widget.setDescendantFocusability(oldFocusability);
}

From source file:org.altusmetrum.AltosDroid.TabsAdapter.java

public void onPageSelected(int position) {
    // Unfortunately when TabHost changes the current tab, it kindly
    // also takes care of putting focus on it when not in touch mode.
    // The jerk.// w  w  w.j  a v a 2 s. c o m
    // This hack tries to prevent this from pulling focus out of our
    // ViewPager.
    TabWidget widget = mTabHost.getTabWidget();
    int oldFocusability = widget.getDescendantFocusability();
    widget.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
    mTabHost.setCurrentTab(position);
    widget.setDescendantFocusability(oldFocusability);
}

From source file:com.simplaapliko.wakeup.sample.ui.DialogDateTime.java

private void initUiWidgets(View rootView) {
    Log.d(TAG, "initUiWidgets()");

    // set up tabhost
    TabHost tabHost = (TabHost) rootView.findViewById(R.id.tabhost);
    tabHost.setup();/*from   w  w w .j a  v  a2 s .  com*/

    TabHost.TabSpec tabSpec;

    // adding tabs
    tabSpec = tabHost.newTabSpec("date");
    tabSpec.setIndicator("Date");
    tabSpec.setContent(R.id.date);
    tabHost.addTab(tabSpec);

    tabSpec = tabHost.newTabSpec("time");
    tabSpec.setIndicator("Time");
    tabSpec.setContent(R.id.time);
    tabHost.addTab(tabSpec);

    TimePicker timePicker = (TimePicker) rootView.findViewById(R.id.time);
    timePicker.setIs24HourView(true); //set to true, because it is more compact
    timePicker.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);

    // init time picker before OnTimeChangedListener() is set
    // otherwise minutes will be set to current time, once setCurrentHour() is called
    timePicker.setCurrentHour(mCalendar.get(Calendar.HOUR_OF_DAY));
    timePicker.setCurrentMinute(mCalendar.get(Calendar.MINUTE));

    timePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {
        @Override
        public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {

            mCalendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
            mCalendar.set(Calendar.MINUTE, minute);
            mCalendar.set(Calendar.SECOND, 0);
        }
    });

    DatePicker datePicker = (DatePicker) rootView.findViewById(R.id.date);
    datePicker.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
    datePicker.init(mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH),
            mCalendar.get(Calendar.DAY_OF_MONTH), new DatePicker.OnDateChangedListener() {
                @Override
                public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {

                    mCalendar.set(Calendar.YEAR, year);
                    mCalendar.set(Calendar.MONTH, monthOfYear);
                    mCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
                }
            });
}