List of usage examples for android.widget TabWidget getChildTabViewAt
public View getChildTabViewAt(int index)
From source file:com.ashlikun.badgeview.BadgeView.java
public void setTargetView(TabWidget target, int tabIndex) { View tabView = target.getChildTabViewAt(tabIndex); setTargetView(tabView); }
From source file:com.jtechme.apphub.privileged.views.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 ww w . j a va2 s . co 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); // Scroll the current tab into visibility if needed. View tab = widget.getChildTabViewAt(position); mTempRect.set(tab.getLeft(), tab.getTop(), tab.getRight(), tab.getBottom()); widget.requestRectangleOnScreen(mTempRect, false); // Make sure the scrollbars are visible for a moment after selection final View contentView = mTabs.get(position); if (contentView instanceof CaffeinatedScrollView) { ((CaffeinatedScrollView) contentView).awakenScrollBars(); } }
From source file:com.android.packageinstaller.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 w w.j av a2 s .c om // 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); // Scroll the current tab into visibility if needed. View tab = widget.getChildTabViewAt(position); mTempRect.set(tab.getLeft(), tab.getTop(), tab.getRight(), tab.getBottom()); widget.requestRectangleOnScreen(mTempRect, false); // Make sure the scrollbars are visible for a moment after selection final View contentView = mTabs.get(position).view; if (contentView instanceof CaffeinatedScrollView) { ((CaffeinatedScrollView) contentView).awakenScrollBars(); } }
From source file:org.eyeseetea.malariacare.DashboardActivity.java
private void addTagToLastTab(String tabName) { TabWidget tabWidget = tabHost.getTabWidget(); int numTabs = tabWidget.getTabCount(); ViewGroup tabIndicator = (ViewGroup) tabWidget.getChildTabViewAt(numTabs - 1); ImageView imageView = (ImageView) tabIndicator.getChildAt(0); imageView.setTag(tabName);/*w ww . j a v a2 s . c o m*/ TextView textView = (TextView) tabIndicator.getChildAt(1); textView.setGravity(Gravity.CENTER); textView.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT; textView.getLayoutParams().width = ViewGroup.LayoutParams.WRAP_CONTENT; }
From source file:com.custom.music.MusicBrowserActivity.java
/** * update play back tab info/* w w w .j av a2 s . c o m*/ */ private void updatePlaybackTab() { final int drawalbeTopPostion = 1; final int opaqueFull = 255; // 100% final int opaqueHalf = 128; // 50% TabWidget tabWidgetTemp = mTabHost.getTabWidget(); TextView tabView = (TextView) tabWidgetTemp.getChildTabViewAt(PLAYBACK_INDEX); boolean enable = true; long id = -1; Drawable[] drawables; Drawable drawableTop = null; int drawableTopAlpha = opaqueFull; if (tabView == null) { return; } try { if (mService != null) { id = mService.getAudioId(); } } catch (RemoteException ex) { Log.e(TAG, "updatePlaybackTab getAudioId remote excption:" + ex, Log.APP); } if (id == -1) { enable = false; drawableTopAlpha = opaqueHalf; } tabView.setEnabled(enable); drawables = tabView.getCompoundDrawables(); drawableTop = drawables[drawalbeTopPostion]; if (drawableTop != null) { drawableTop.setAlpha(drawableTopAlpha); } Log.i(TAG, "updatePlaybackTab:" + enable, Log.APP); }
From source file:com.android.music.MusicBrowserActivity.java
/** * update play back tab info/*from w w w . ja v a2 s.c om*/ */ private void updatePlaybackTab() { final int drawalbeTopPostion = 1; final int opaqueFull = 255; // 100% final int opaqueHalf = 128; // 50% TabWidget tabWidgetTemp = mTabHost.getTabWidget(); TextView tabView = (TextView) tabWidgetTemp.getChildTabViewAt(PLAYBACK_INDEX); boolean enable = true; long id = -1; Drawable[] drawables; Drawable drawableTop = null; int drawableTopAlpha = opaqueFull; if (tabView == null) { return; } try { if (mService != null) { id = mService.getAudioId(); } } catch (RemoteException ex) { MusicLogUtils.e(TAG, "updatePlaybackTab getAudioId remote excption:" + ex); } if (id == -1) { enable = false; drawableTopAlpha = opaqueHalf; } tabView.setEnabled(enable); drawables = tabView.getCompoundDrawables(); drawableTop = drawables[drawalbeTopPostion]; if (drawableTop != null) { drawableTop.setAlpha(drawableTopAlpha); } MusicLogUtils.d(TAG, "updatePlaybackTab:" + enable); }
From source file:com.custom.music.MusicBrowserActivity.java
/** * initial tab host/*from w w w.ja v a 2 s.c o m*/ */ private void initTab() { Log.i(TAG, ">>> initTab", Log.APP); final TabWidget tabWidget = (TabWidget) getLayoutInflater().inflate(R.layout.buttonbar, null); mOrientaiton = getResources().getConfiguration().orientation; mTabCount = tabWidget.getChildCount(); View tabView; /// M:remove fake menu if (mHasMenukey) { mTabCount--; } for (int i = 0; i < mTabCount; i++) { tabView = tabWidget.getChildAt(0); if (tabView != null) { tabWidget.removeView(tabView); } Log.i(TAG, "addTab:" + i, Log.APP); mTabHost.addTab( mTabHost.newTabSpec(getStringId(i)).setIndicator(tabView).setContent(android.R.id.tabcontent)); } if (mOrientaiton == Configuration.ORIENTATION_PORTRAIT) { TabWidget tabWidgetTemp = mTabHost.getTabWidget(); //update by zjw //PLAYBACK_INDEX for (int i = 0; i < mTabCount; i++) { tabView = tabWidgetTemp.getChildTabViewAt(i); if (tabView != null) { tabView.setVisibility(View.GONE); } Log.i(TAG, "set tab gone:" + i, Log.APP); } } Log.i(TAG, "initTab >>>", Log.APP); }
From source file:com.android.music.MusicBrowserActivity.java
/** * initial tab host/* ww w .java 2s . com*/ */ private void initTab() { if (mPermissionReqProcessed == true) { MusicLogUtils.d(TAG, "initTab>>"); final TabWidget tabWidget = (TabWidget) getLayoutInflater().inflate(R.layout.buttonbar, null); mOrientaiton = getResources().getConfiguration().orientation; mTabCount = tabWidget.getChildCount(); View tabView; /// M:remove fake menu if (mHasMenukey) { mTabCount--; } for (int i = 0; i < mTabCount; i++) { tabView = tabWidget.getChildAt(0); if (tabView != null) { tabWidget.removeView(tabView); } MusicLogUtils.d(TAG, "addTab:" + i); mTabHost.addTab(mTabHost.newTabSpec(getStringId(i)).setIndicator(tabView) .setContent(android.R.id.tabcontent)); } if (mOrientaiton == Configuration.ORIENTATION_PORTRAIT) { TabWidget tabWidgetTemp = mTabHost.getTabWidget(); for (int i = PLAYBACK_INDEX; i < mTabCount; i++) { tabView = tabWidgetTemp.getChildTabViewAt(i); if (tabView != null) { tabView.setVisibility(View.GONE); } MusicLogUtils.d(TAG, "set tab gone:" + i); } } MusicLogUtils.d(TAG, "initTab<<"); } }
From source file:br.com.viniciuscr.notification2android.mediaPlayer.MusicUtils.java
static boolean updateButtonBar(Activity a, int highlight) { final TabWidget ll = (TabWidget) a.findViewById(R.id.buttonbar); boolean withtabs = false; Intent intent = a.getIntent();/*from www . j a va 2 s . c o m*/ if (intent != null) { withtabs = intent.getBooleanExtra("withtabs", false); } if (highlight == 0 || !withtabs) { ll.setVisibility(View.GONE); return withtabs; } else if (withtabs) { ll.setVisibility(View.VISIBLE); } for (int i = ll.getChildCount() - 1; i >= 0; i--) { View v = ll.getChildAt(i); boolean isActive = (v.getId() == highlight); if (isActive) { ll.setCurrentTab(i); sActiveTabIndex = i; } v.setTag(i); v.setOnFocusChangeListener(new View.OnFocusChangeListener() { public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { for (int i = 0; i < ll.getTabCount(); i++) { if (ll.getChildTabViewAt(i) == v) { ll.setCurrentTab(i); processTabClick((Activity) ll.getContext(), v, ll.getChildAt(sActiveTabIndex).getId()); break; } } } } }); v.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { processTabClick((Activity) ll.getContext(), v, ll.getChildAt(sActiveTabIndex).getId()); } }); } return withtabs; }
From source file:com.android.music.MusicBrowserActivity.java
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (mPermissionReqProcessed == true) { MusicLogUtils.d(TAG, "onConfigurationChanged>>"); TabWidget tabWidgetTemp = mTabHost.getTabWidget(); View tabView;//w ww .j a v a2s. c o m Activity activity; int viewStatusForTab = View.GONE; mOrientaiton = newConfig.orientation; if (mOrientaiton == Configuration.ORIENTATION_LANDSCAPE) { MusicLogUtils.d(TAG, "onConfigurationChanged--LandScape"); viewStatusForTab = View.VISIBLE; } /// M: load tab which is alive only for Landscape; for (int i = PLAYBACK_INDEX; i < mTabCount; i++) { tabView = tabWidgetTemp.getChildTabViewAt(i); if (tabView != null) { tabView.setVisibility(viewStatusForTab); } } /// M: notify sub Activity for configuration changed; for (int i = 0; i < PLAYBACK_INDEX; i++) { activity = mActivityManager.getActivity(getStringId(i)); if (activity != null) { activity.onConfigurationChanged(newConfig); } } if (!mHasMenukey) { boolean popupMenuShowing = mPopupMenuShowing; if (popupMenuShowing && mPopupMenu != null) { mPopupMenu.dismiss(); MusicLogUtils.d(TAG, "changeFakeMenu:mPopupMenu.dismiss()"); } MusicLogUtils.d(TAG, "changeFakeMenu:popupMenuShowing=" + popupMenuShowing); createFakeMenu(); if (!mSearchViewShowing) { mOverflowMenuButton.setEnabled(true); } if (popupMenuShowing && mOverflowMenuButton != null) { /**M: Disable the sound effect while the configuration changed.@**/ mOverflowMenuButton.setSoundEffectsEnabled(false); mOverflowMenuButton.performClick(); mOverflowMenuButton.setSoundEffectsEnabled(true); /**@}**/ MusicLogUtils.d(TAG, "changeFakeMenu:performClick()"); } } if (mService != null) { MusicLogUtils.d(TAG, "mSearchViewShowing:" + mSearchViewShowing); if (mSearchViewShowing) { mSearchButton.setVisibility(View.GONE); } else { mSearchButton.setVisibility(View.VISIBLE); } MusicUtils.updateNowPlaying(MusicBrowserActivity.this, mOrientaiton); updatePlaybackTab(); } /**M: Added for forcing init last visible view.@{**/ MusicLogUtils.d(TAG, "onConfigurationChanged--mCurrentTab = " + mCurrentTab); mTabHost.setCurrentTab(mCurrentTab); mViewPager.setAdapter(new MusicPagerAdapter()); onTabChanged(getStringId(mCurrentTab)); /**@}**/ MusicLogUtils.d(TAG, "onConfigurationChanged<<"); } }