@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. // 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); // Scroll the current tab into visibility if needed. View tab = widget.getChildTabViewAt(position); tempRect.set(tab.getLeft(), tab.getTop(), tab.getRight(), tab.getBottom()); widget.requestRectangleOnScreen(tempRect, false); // Make sure the scrollbars are visible for a moment after selection final View contentView = tabs.get(position); if (contentView instanceof CaffeinatedScrollView) { ((CaffeinatedScrollView) contentView).awakenScrollBars(); } }
private void changeTabBackGround() { // 改变选项卡的颜色 // 得到当前选中选项卡的索引 int index = getTabHost().getCurrentTab(); // 调用tabhost中的getTabWidget()方法得到TabWidget TabWidget tabWidget = getTabHost().getTabWidget(); // 得到选项卡的数量 int count = tabWidget.getChildCount(); // 循环判断,只有点中的索引值改变背景颜色,其他的则恢复未选中的颜色 for (int i = 0; i < count; i++) { View view = tabWidget.getChildAt(i); TextView tv = (TextView) tabWidget.getChildAt(i).findViewById( android.R.id.title); tv.setTextSize(20); if (index == i) { view.setBackgroundResource(color.holo_blue_dark); } else { view.setBackgroundResource(color.holo_blue_light); } } }
public void applyTo(View target) { LayoutParams lp = target.getLayoutParams(); ViewParent parent = target.getParent(); FrameLayout container = new FrameLayout(this.context); if (target instanceof TabWidget) { target = ((TabWidget) target).getChildTabViewAt(this.targetTabIndex); this.target = target; ((ViewGroup) target).addView(container, new LayoutParams(-1, -1)); setVisibility(8); container.addView(this); return; } ViewGroup group = (ViewGroup) parent; int index = group.indexOfChild(target); group.removeView(target); group.addView(container, index, lp); container.addView(target); setVisibility(8); container.addView(this); group.invalidate(); }
public void setTabWidget(Context context, TabWidget tabwidget) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); int themeSet = Integer.parseInt(sharedPreferences.getString("preferences_theme_set", "0")); int colorThemeSet = Integer.parseInt(sharedPreferences.getString("preferences_color_theme_set", "7")); for(int i = 0; i < tabwidget.getChildCount(); i++) { View v = tabwidget.getChildAt(i); TextView textview = (TextView)v.findViewById(android.R.id.title); if(textview == null) { continue; } v.setBackgroundResource(tabwidget_drawable[themeSet][colorThemeSet]); } }
private void ensureHierarchy(Context context) { // If owner hasn't made its own view hierarchy, then as a convenience // we will construct a standard one here. if (findViewById(android.R.id.tabs) == null) { LinearLayout ll = new LinearLayout(context); ll.setOrientation(LinearLayout.VERTICAL); addView(ll, new LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); TabWidget tw = new TabWidget(context); tw.setId(android.R.id.tabs); tw.setOrientation(TabWidget.HORIZONTAL); ll.addView(tw, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0)); FrameLayout fl = new FrameLayout(context); fl.setId(android.R.id.tabcontent); ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0)); mRealTabContent = fl = new FrameLayout(context); mRealTabContent.setId(mContainerId); ll.addView(fl, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, 0, 1)); } }
@Override public RPCMessage handleRequest(RPCMessage request, Solo solo, Map varCache) { RPCMessage response; int hash = Integer.parseInt((String) request.getArgs().get(0));//获取hashcode TabWidget tabWidget = (TabWidget) varCache.get(hash); if (tabWidget != null) { solo.clickOnView(tabWidget.getChildAt(Integer.parseInt((String) request.getArgs().get(1)))); response = RPCMessage.makeSuccessResult(); } else { response = ErrorResponseHelper.makeViewNotFoundErrorResponse(getClass()); } return response; }
@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. // 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(); } }
public Tab showTab(String name) { if (tabHost != null) { for (int i = 0; i < tabs.size(); i++) { Tab tab = tabs.get(i); if (tab.getName().equals(name)) { tab.setHidden(false); TabWidget widget = tabHost.getTabWidget(); widget.getChildAt(i).setVisibility(View.VISIBLE); tabHost.setCurrentTab(i); if(tab.getScrollViewForTab() != null){ tab.getScrollViewForTab().scrollTo(0, 0); } return tab; } } } return null; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); tabHost = getTabHost(); layout = new LinearLayout(this, ComponentConstants.LAYOUT_ORIENTATION_VERTICAL); tabholder = new TabWidget(this); layout.add(tabholder); String classname = getClass().getName(); int lastDot = classname.lastIndexOf('.'); tabformName = classname.substring(lastDot + 1); Log.d(LOG_TAG, "TabForm " + tabformName + " got onCreate"); $define(); }
public static TabHost createTabHost(Context context) { // Create the TabWidget (the tabs) TabWidget tabWidget = new TabWidget(context); tabWidget.setId(android.R.id.tabs); // Create the FrameLayout (the content area) FrameLayout frame = new FrameLayout(context); frame.setId(android.R.id.tabcontent); LinearLayout.LayoutParams frameLayoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1); frameLayoutParams.setMargins(4, 4, 4, 4); frame.setLayoutParams(frameLayoutParams); // Create the container for the above widgets LinearLayout tabHostLayout = new LinearLayout(context); tabHostLayout.setOrientation(LinearLayout.VERTICAL); tabHostLayout.addView(tabWidget); tabHostLayout.addView(frame); // Create the TabHost and add the container to it. TabHost tabHost = new TabHost(context, null); tabHost.addView(tabHostLayout); tabHost.setup(); return tabHost; }
public static void setTabHostSelector(TabHost host, int selector) { if (host == null) { return; } TabWidget widget = host.getTabWidget(); if (widget == null) { return; } for(int i = 0; i < widget.getChildCount(); i++) { View v = widget.getChildAt(i); if (v == null) { continue; } TextView tv = (TextView) v.findViewById(android.R.id.title); if (tv == null) { continue; } v.setBackgroundResource(selector); } }
private void a(View view) { android.view.ViewGroup.LayoutParams layoutparams = view.getLayoutParams(); android.view.ViewParent viewparent = view.getParent(); FrameLayout framelayout = new FrameLayout(i); if (view instanceof TabWidget) { View view1 = ((TabWidget)view).getChildTabViewAt(q); j = view1; ((ViewGroup)view1).addView(framelayout, new android.view.ViewGroup.LayoutParams(-1, -1)); setVisibility(8); framelayout.addView(this); return; } else { ViewGroup viewgroup = (ViewGroup)viewparent; int i1 = viewgroup.indexOfChild(view); viewgroup.removeView(view); viewgroup.addView(framelayout, i1, layoutparams); framelayout.addView(view); setVisibility(8); framelayout.addView(this); viewgroup.invalidate(); return; } }
private void a(Context context, AttributeSet attributeset) { TypedArray typedarray = context.obtainStyledAttributes(attributeset, new int[] { 0x10100f3 }, 0, 0); e = typedarray.getResourceId(0, 0); typedarray.recycle(); super.setOnTabChangedListener(this); if (findViewById(0x1020013) == null) { LinearLayout linearlayout = new LinearLayout(context); linearlayout.setOrientation(1); addView(linearlayout, new android.widget.FrameLayout.LayoutParams(-1, -1)); TabWidget tabwidget = new TabWidget(context); tabwidget.setId(0x1020013); tabwidget.setOrientation(0); linearlayout.addView(tabwidget, new android.widget.LinearLayout.LayoutParams(-1, -2, 0.0F)); FrameLayout framelayout = new FrameLayout(context); framelayout.setId(0x1020011); linearlayout.addView(framelayout, new android.widget.LinearLayout.LayoutParams(0, 0, 0.0F)); FrameLayout framelayout1 = new FrameLayout(context); b = framelayout1; b.setId(e); linearlayout.addView(framelayout1, new android.widget.LinearLayout.LayoutParams(-1, 0, 1.0F)); } }
private void setUpTabs() { List<TabModel> tabs = tabsToAdd(); fragmentManager = getSupportFragmentManager(); tabHost.setup(this, fragmentManager, android.R.id.tabcontent); for (int i = 0; i < tabs.size(); i ++){ TabModel tab = tabs.get(i); tabHost.addTab( tabHost.newTabSpec(tab.getTag()).setIndicator(tab.getName(), null), tab.getFragmentClass(), tab.getFragmentArgs()); } TabWidget widget = tabHost.getTabWidget(); for (int i = 0; i < widget.getChildCount(); i++) { final TextView tv = (TextView) widget.getChildAt(i).findViewById( android.R.id.title); tv.setTextColor(this.getResources().getColorStateList( R.color.tab_selector)); tv.setSingleLine(true); tv.setAllCaps(true); } }
private void ensureHierarchy(Context context) { if (findViewById(0x1020013) == null) { LinearLayout linearlayout = new LinearLayout(context); linearlayout.setOrientation(1); addView(linearlayout, new android.widget.FrameLayout.LayoutParams(-1, -1)); Object obj = new TabWidget(context); ((TabWidget) (obj)).setId(0x1020013); ((TabWidget) (obj)).setOrientation(0); linearlayout.addView(((View) (obj)), new android.widget.LinearLayout.LayoutParams(-1, -2, 0.0F)); obj = new FrameLayout(context); ((FrameLayout) (obj)).setId(0x1020011); linearlayout.addView(((View) (obj)), new android.widget.LinearLayout.LayoutParams(0, 0, 0.0F)); context = new FrameLayout(context); mRealTabContent = context; mRealTabContent.setId(mContainerId); linearlayout.addView(context, new android.widget.LinearLayout.LayoutParams(-1, 0, 1.0F)); } }
private void ˊ(Context paramContext) { if (findViewById(16908307) == null) { LinearLayout localLinearLayout = new LinearLayout(paramContext); localLinearLayout.setOrientation(1); addView(localLinearLayout, new FrameLayout.LayoutParams(-1, -1)); TabWidget localTabWidget = new TabWidget(paramContext); localTabWidget.setId(16908307); localTabWidget.setOrientation(0); localLinearLayout.addView(localTabWidget, new LinearLayout.LayoutParams(-1, -2, 0.0F)); FrameLayout localFrameLayout1 = new FrameLayout(paramContext); localFrameLayout1.setId(16908305); localLinearLayout.addView(localFrameLayout1, new LinearLayout.LayoutParams(0, 0, 0.0F)); FrameLayout localFrameLayout2 = new FrameLayout(paramContext); this.ˋ = localFrameLayout2; this.ˋ.setId(this.ᐝ); localLinearLayout.addView(localFrameLayout2, new LinearLayout.LayoutParams(-1, 0, 1.0F)); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTabHost = (TabHost)findViewById(android.R.id.tabhost); mTabHost.setup(); mTabs = (TabWidget)findViewById(android.R.id.tabs); ViewStub vStub = (ViewStub) findViewById(R.id.new_home_menu); mMenuContainer = (FrameLayout) vStub.inflate(); mViewPager = (ViewPager)findViewById(R.id.pager); mLoadingView = makeEmptyLoadingView(this, (RelativeLayout)findViewById(R.id.tabs_content)); setScrollerTime(800); albumItem = (DisplayItem) getIntent().getSerializableExtra("item"); setUserFragmentClass(); getSupportLoaderManager().initLoader(TabsGsonLoader.LOADER_ID, null, this); if (savedInstanceState != null) { mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab")); } }
@Override protected void prepare() { TabItem Home = new TabItem(R.drawable.base_home, new Intent(this, HomeActivity.class)); TabItem Fclass = new TabItem(R.drawable.base_fclass_bg, new Intent( this, FclassHomeActivity.class)); TabItem ShopCart = new TabItem(R.drawable.base_shopcart, new Intent( this, ShopCartActivity.class)); TabItem MyCenter = new TabItem(R.drawable.base_mycenter, new Intent( this, MycenterHomeActivity.class)); mItems = new ArrayList<TabItem>(); mItems.add(Home); mItems.add(Fclass); mItems.add(ShopCart); mItems.add(MyCenter); @SuppressWarnings("deprecation") TabWidget tabWidget = getTabWidget(); tabWidget.setDividerDrawable(R.drawable.tab_divider); }
private TabHost createTabs() { TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost); if (tabHost == null) return null; tabHost.setup(); addTab(tabHost, "contact_query", R.string.label_keyword, R.id.tabContactQuery); addTab(tabHost, "ip_query", R.string.label_ip, R.id.tabIPQuery); TabWidget tabWidget = tabHost.getTabWidget(); if (tabWidget == null) return tabHost; for (int i = 0; i < tabWidget.getChildCount(); i++) { tabWidget.getChildAt(i).getLayoutParams().height = 60; } return tabHost; }
public void setAppear(int flag){ tabWidget = (TabWidget) findViewById(android.R.id.tabs); tabWidget.setBackgroundResource(R.drawable.black_bg); for (int i = 0; i < tabWidget.getChildCount(); i++) { final TextView tv = (TextView) tabWidget.getChildAt(i) .findViewById(android.R.id.title); tabWidget.getChildAt(i).getLayoutParams().height = 60; if (i == flag) { tabWidget.getChildAt(i).setBackgroundResource( R.drawable.tab_bankground);//设置背景 tv.setTextColor(Color.rgb(202, 151, 0)); } else { tabWidget.getChildAt(i) .setBackgroundResource(R.drawable.tab_bankground2); tv.setTextColor(Color.WHITE); tabWidget.getChildAt(i).setClickable(true); } tv.setTextSize(15); } }
private void ensureHierarchy(Context context) { // If owner hasn't made its own view hierarchy, then as a convenience // we will construct a standard one here. if (findViewById(android.R.id.tabs) == null) { LinearLayout ll = new LinearLayout(context); ll.setOrientation(LinearLayout.VERTICAL); addView(ll, new LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); TabWidget tw = new TabWidget(context); tw.setId(android.R.id.tabs); tw.setOrientation(TabWidget.HORIZONTAL); ll.addView(tw, new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0)); FrameLayout fl = new FrameLayout(context); fl.setId(android.R.id.tabcontent); ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0)); mRealTabContent = fl = new FrameLayout(context); mRealTabContent.setId(mContainerId); ll.addView(fl, new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, 0, 1)); } }
@Override protected final void onAttachedToWindow() { super.onAttachedToWindow(); mTabBar = (TabWidget) findViewById(android.R.id.tabs); // set custom divider work incorrect on version <= 3.0 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mTabBar.setDividerDrawable(R.color.divider); } }
private void update() { Collections.sort(simContacts); Collections.sort(phoneContacts); simAdapter.notifyDataSetChanged(); phoneAdapter.notifyDataSetChanged(); TabWidget tabWidget = getTabHost().getTabWidget(); TextView labelPhone = (TextView) tabWidget.getChildAt(0).findViewById(android.R.id.title); TextView labelSim = (TextView) tabWidget.getChildAt(1).findViewById(android.R.id.title); labelPhone.setText(getString(R.string.phone_tab_title) + " (" + phoneContacts.size() + ")"); labelSim.setText(getString(R.string.sim_tab_title) + " (" + simContacts.size() + ")"); }
private void applyTo(View target) { LayoutParams lp = target.getLayoutParams(); ViewParent parent = target.getParent(); FrameLayout container = new FrameLayout(context); if (target instanceof TabWidget) { // set target to the relevant tab child container target = ((TabWidget) target).getChildTabViewAt(targetTabIndex); this.target = target; ((ViewGroup) target).addView(container, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); this.setVisibility(View.GONE); container.addView(this); } else { ViewGroup group = (ViewGroup) parent; int index = group.indexOfChild(target); group.removeView(target); group.addView(container, index, lp); container.addView(target); this.setVisibility(View.GONE); container.addView(this); group.invalidate(); } }
/** * Callback for when a tab is selected. * @param position The position of the selected tab */ @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. // 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); }
private void ensureHierarchy(Context context) { // If owner hasn't made its own view hierarchy, then as a convenience // we will construct a standard one here. if (findViewById(android.R.id.tabs) == null) { LinearLayout ll = new LinearLayout(context); ll.setOrientation(LinearLayout.VERTICAL); addView(ll, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); TabWidget tw = new TabWidget(context); tw.setId(android.R.id.tabs); tw.setOrientation(TabWidget.HORIZONTAL); ll.addView(tw, new LinearLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0)); FrameLayout fl = new FrameLayout(context); fl.setId(android.R.id.tabcontent); ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0)); mRealTabContent = fl = new FrameLayout(context); mRealTabContent.setId(mContainerId); ll.addView(fl, new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, 0, 1)); } }
private void ensureHierarchy(Context context) { // If owner hasn't made its own view hierarchy, then as a convenience // we will construct a standard one here. if (findViewById(android.R.id.tabs) == null) { LinearLayout ll = new LinearLayout(context); ll.setOrientation(LinearLayout.VERTICAL); addView(ll, new LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); TabWidget tw = new TabWidget(context); tw.setId(android.R.id.tabs); tw.setOrientation(TabWidget.HORIZONTAL); ll.addView(tw, new LinearLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0)); FrameLayout fl = new FrameLayout(context); fl.setId(android.R.id.tabcontent); ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0)); mRealTabContent = fl = new FrameLayout(context); mRealTabContent.setId(mContainerId); ll.addView(fl, new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, 0, 1)); } }
private void ensureHierarchy(Context context) { // If owner hasn't made its own view hierarchy, then as a convenience // we will construct a standard one here. if (findViewById(android.R.id.tabs) == null) { LinearLayout ll = new LinearLayout(context); ll.setOrientation(LinearLayout.VERTICAL); addView(ll, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); TabWidget tw = new TabWidget(context); tw.setId(android.R.id.tabs); tw.setOrientation(TabWidget.HORIZONTAL); ll.addView(tw, new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0)); FrameLayout fl = new FrameLayout(context); fl.setId(android.R.id.tabcontent); ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0)); mRealTabContent = fl = new FrameLayout(context); mRealTabContent.setId(mContainerId); ll.addView(fl, new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, 0, 1)); } }
public static SubjectFactory<TabWidgetSubject, TabWidget> type() { return new SubjectFactory<TabWidgetSubject, TabWidget>() { @Override public TabWidgetSubject getSubject(FailureStrategy fs, TabWidget that) { return new TabWidgetSubject(fs, that); } }; }
private void applyTo(View target) { LayoutParams lp = target.getLayoutParams(); ViewParent parent = target.getParent(); FrameLayout container = new FrameLayout(context); if (target instanceof TabWidget) { // set target to the relevant tab child container target = ((TabWidget) target).getChildTabViewAt(targetTabIndex); this.target = target; ((ViewGroup) target).addView(container, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); this.setVisibility(View.GONE); container.addView(this); } else { // TODO verify that parent is indeed a ViewGroup ViewGroup group = (ViewGroup) parent; int index = group.indexOfChild(target); group.removeView(target); group.addView(container, index, lp); container.addView(target); this.setVisibility(View.GONE); container.addView(this); group.invalidate(); } }
private void applyTo(View target) { LayoutParams lp = target.getLayoutParams(); ViewParent parent = target.getParent(); FrameLayout container = new FrameLayout(context); if (target instanceof TabWidget) { // set target to the relevant tab child container target = ((TabWidget) target).getChildTabViewAt(targetTabIndex); this.target = target; ((ViewGroup) target).addView(container, new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); this.setVisibility(View.GONE); container.addView(this); } else { // verify that parent is indeed a ViewGroup ViewGroup group = (ViewGroup) parent; int index = group.indexOfChild(target); group.removeView(target); group.addView(container, index, lp); container.addView(target); this.setVisibility(View.GONE); container.addView(this); group.invalidate(); } }