List of usage examples for android.view ViewGroup getChildCount
public int getChildCount()
From source file:com.mfh.framework.uikit.widget.SideSlidingTabStrip.java
/** * ViewPager/* www .j av a 2 s .c om*/ * * @param viewPager * ViewPager */ public void setViewPager(ViewPager viewPager) { if (disableViewPager) return; this.viewPager = viewPager; this.viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { ViewGroup tabsLayout = getTabsLayout(); if (position < tabsLayout.getChildCount()) { View view = tabsLayout.getChildAt(position); if (view != null) { currentPosition = position; currentPositionOffset = positionOffset; scrollToChild(position, (int) (positionOffset * view.getWidth())); invalidate(); } } if (onPageChangeListener != null) { onPageChangeListener.onPageScrolled(position, positionOffset, positionOffsetPixels); } } @Override public void onPageSelected(int position) { // ZLogger.d("Main onPageSelected " + position); selectedTab(position); if (onPageChangeListener != null) { onPageChangeListener.onPageSelected(position); } if (listener != null) listener.onChanged(position); } @Override public void onPageScrollStateChanged(int state) { if (onPageChangeListener != null) { onPageChangeListener.onPageScrollStateChanged(state); } } }); // //deprecated // this.viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { // @Override // public void onPageSelected(int position) { // selectedTab(position); // if (onPageChangeListener != null) { // onPageChangeListener.onPageSelected(position); // } // if (listener != null) // listener.onChanged(position); // } // // @Override // public void onPageScrolled(int nextPagePosition, // float positionOffset, int positionOffsetPixels) { // ViewGroup tabsLayout = getTabsLayout(); // if (nextPagePosition < tabsLayout.getChildCount()) { // View view = tabsLayout.getChildAt(nextPagePosition); // if (view != null) { // currentPosition = nextPagePosition; // currentPositionOffset = positionOffset; // scrollToChild(nextPagePosition, // (int) (positionOffset * view.getWidth())); // invalidate(); // } // } // if (onPageChangeListener != null) { // onPageChangeListener.onPageScrolled(nextPagePosition, // positionOffset, positionOffsetPixels); // } // } // // @Override // public void onPageScrollStateChanged(int arg0) { // if (onPageChangeListener != null) { // onPageChangeListener.onPageScrollStateChanged(arg0); // } // } // }); requestLayout(); }
From source file:com.mfh.framework.uikit.widget.SideSlidingTabStrip.java
/** * ?TAB// w ww .j a va 2 s . c om */ public void selectedTab(int currentSelectedTabPosition) { ViewGroup tabsLayout = getTabsLayout(); if (currentSelectedTabPosition > -1 && tabsLayout != null && currentSelectedTabPosition < tabsLayout.getChildCount()) { if (currentSelectedTabView != null) { currentSelectedTabView.setSelected(false); } currentSelectedTabView = tabsLayout.getChildAt(currentSelectedTabPosition); if (currentSelectedTabView != null) { currentSelectedTabView.setSelected(true); } } }
From source file:com.mooshim.mooshimeter.main.ScanActivity.java
private void refreshMeterTile(final MooshimeterDevice d, final ViewGroup wrapper) { if (wrapper.getChildCount() == 0) { Log.e(TAG, "Received empty wrapper"); }/* w w w . j a v a 2 s . co m*/ if (wrapper.getChildCount() > 0) { // Update the title bar int rssi = d.mRssi; String name; String build; if (d.mOADMode) { name = "Bootloader"; } else { name = d.getBLEDevice().getName(); if (name == null) { name = "Unknown device"; } } if (d.mBuildTime == 0) { build = "Invalid firmware"; } else { build = "Build: " + d.mBuildTime; } String descr = name + "\n" + build + "\nRssi: " + rssi + " dBm"; ((TextView) wrapper.findViewById(R.id.descr)).setText(descr); final Button bv = (Button) wrapper.findViewById(R.id.btnConnect); int bgid = d.mConnectionState == BluetoothProfile.STATE_CONNECTED ? R.drawable.connected : R.drawable.disconnected; bv.setBackground(getResources().getDrawable(bgid)); // Set the click listeners bv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { toggleConnectionState(bv, d); } }); } if (d.mInitialized && !d.isInOADMode()) { // We are representing a connected meter if (wrapper.getChildCount() != 2) { // We need to create a new value pane wrapper.addView(mInflater.inflate(R.layout.element_mm_readingsbar, mDeviceScrollView, false)); } Util.dispatch(new Runnable() { @Override public void run() { if (!d.isNotificationEnabled(d.getChar(MooshimeterDevice.mUUID.METER_SAMPLE))) { // We need to enable notifications d.playSampleStream(new Runnable() { @Override public void run() { TextView ch1 = (TextView) wrapper.findViewById(R.id.ch1_value_label); TextView ch2 = (TextView) wrapper.findViewById(R.id.ch2_value_label); TextView ch1_unit = (TextView) wrapper.findViewById(R.id.ch1_unit_label); TextView ch2_unit = (TextView) wrapper.findViewById(R.id.ch2_unit_label); valueLabelRefresh(0, d, ch1, ch1_unit); valueLabelRefresh(1, d, ch2, ch2_unit); } }); } } }); } else { //We are representing a disconnected meter or a meter in OAD mode if (wrapper.getChildCount() == 2) { // We need to eliminate a pane wrapper.removeViewAt(1); } } }
From source file:com.bt.download.android.gui.adapters.TransferListAdapter.java
private void initTouchFeedback(View v, TransferItem item) { v.setOnClickListener(viewOnClickListener); v.setOnLongClickListener(viewOnLongClickListener); v.setTag(item);//from ww w. ja v a 2s.c om if (v instanceof ViewGroup) { ViewGroup vg = (ViewGroup) v; int count = vg.getChildCount(); for (int i = 0; i < count; i++) { View child = vg.getChildAt(i); initTouchFeedback(child, item); } } }
From source file:me.xiaopan.psts.PagerSlidingTabStrip.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (bottomLineColor != -1 && bottomLineHeight != -1) { if (bottomLinePaint == null) { bottomLinePaint = new Paint(); bottomLinePaint.setColor(bottomLineColor); }//from w w w . ja v a2 s. c o m canvas.drawRect(0, getBottom() - bottomLineHeight, getRight(), getBottom(), bottomLinePaint); } if (disableViewPager) return; /* ? */ ViewGroup tabsLayout = getTabsLayout(); if (tabsLayout != null && tabsLayout.getChildCount() > 0 && slidingBlockDrawable != null) { View currentTab = tabsLayout.getChildAt(currentPosition); if (currentTab != null) { float slidingBlockLeft = currentTab.getLeft(); float slidingBlockRight = currentTab.getRight(); if (currentPositionOffset > 0f && currentPosition < tabsLayout.getChildCount() - 1) { View nextTab = tabsLayout.getChildAt(currentPosition + 1); if (nextTab != null) { final float nextTabLeft = nextTab.getLeft(); final float nextTabRight = nextTab.getRight(); slidingBlockLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * slidingBlockLeft); slidingBlockRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * slidingBlockRight); } } // ? if (disableTensileSlidingBlock) { int center = (int) (slidingBlockLeft + (slidingBlockRight - slidingBlockLeft) / 2); slidingBlockLeft = center - slidingBlockDrawable.getIntrinsicWidth() / 2; slidingBlockRight = center + slidingBlockDrawable.getIntrinsicWidth() / 2; } slidingBlockDrawable.setBounds((int) slidingBlockLeft, getHeight() - slidingBlockDrawable.getIntrinsicHeight(), (int) slidingBlockRight, getHeight()); slidingBlockDrawable.draw(canvas); } } }
From source file:com.liushengfan.test.customerviewgroup.view.PagerSlidingTabStrip.java
private void changeTextColor(int position) { for (int i = 0; i < tabCount; i++) { View view = tabsContainer.getChildAt(i); if (view instanceof TextView) { TextView tab = (TextView) view; if (position == i) { tab.setTextColor(getResources().getColor(R.color.sgk_red_common_bg)); } else { tab.setTextColor(getResources().getColor(R.color.sgk_black_text_color)); }/*from www . j av a 2s . co m*/ } else if (view instanceof ViewGroup) { ViewGroup group = (ViewGroup) view; for (int j = 0; j < group.getChildCount(); j++) { View groupChild = group.getChildAt(j); if (groupChild instanceof TextView) { TextView tab = (TextView) groupChild; if (position == i) { tab.setTextColor(getResources().getColor(R.color.sgk_red_common_bg)); } else { tab.setTextColor(getResources().getColor(R.color.sgk_black_text_color)); } } } } } }
From source file:com.mfh.framework.uikit.widget.SideSlidingTabStrip.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); if (!allowWidthFull) return;/*w w w . java 2s.c o m*/ ViewGroup tabsLayout = getTabsLayout(); if (tabsLayout == null || tabsLayout.getMeasuredWidth() >= getMeasuredWidth()) return; if (tabsLayout.getChildCount() <= 0) return; if (tabViews == null) { tabViews = new ArrayList<>(); } else { tabViews.clear(); } for (int w = 0; w < tabsLayout.getChildCount(); w++) { tabViews.add(tabsLayout.getChildAt(w)); } adjustChildHeightWithParent(tabViews, getMeasuredHeight() - tabsLayout.getPaddingTop() - tabsLayout.getPaddingBottom(), widthMeasureSpec, heightMeasureSpec); super.onMeasure(widthMeasureSpec, heightMeasureSpec); }
From source file:com.cgearc.yummy.Act_Main.java
public void setActionBarTranslation(float y) { // Figure out the actionbar height int actionBarHeight = getActionBarHeight(); // A hack to add the translation to the action bar ViewGroup content = ((ViewGroup) findViewById(android.R.id.content).getParent()); int children = content.getChildCount(); for (int i = 0; i < children; i++) { View child = content.getChildAt(i); if (child.getId() != android.R.id.content) { child.setTranslationY(y);//from w w w . j a v a2 s . c o m // if (y <= -actionBarHeight) { // child.setVisibility(View.GONE); // } else { // child.setVisibility(View.VISIBLE); // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // // child.setTranslationY(y); // } else { // AnimatorProxy.wrap(child).setTranslationY(y); // } // } } } }
From source file:com.goliathonline.android.kegbot.ui.DrinkDetailFragment.java
private void updateLinksTab(Cursor cursor) { ViewGroup container = (ViewGroup) mRootView.findViewById(R.id.links_container); // Remove all views but the 'empty' view int childCount = container.getChildCount(); if (childCount > 1) { container.removeViews(1, childCount - 1); }//from ww w . j a v a 2 s. co m LayoutInflater inflater = getLayoutInflater(null); boolean hasLinks = false; container.findViewById(R.id.empty_links).setVisibility(hasLinks ? View.GONE : View.VISIBLE); }
From source file:com.dattasmoon.pebble.plugin.NotificationService.java
private String dumpViewGroup(int depth, ViewGroup vg, String existing_text) { String text = ""; Log.d(Constants.LOG_TAG, "root view, depth:" + depth + "; view: " + vg); for (int i = 0; i < vg.getChildCount(); ++i) { View v = vg.getChildAt(i); if (Constants.IS_LOGGABLE) { Log.d(Constants.LOG_TAG, "depth: " + depth + "; " + v.getClass().toString() + "; view: " + v); }/* w ww. j a v a2 s. co m*/ if (v.getId() == android.R.id.title || v instanceof android.widget.Button || v.getClass().toString().contains("android.widget.DateTimeView")) { if (Constants.IS_LOGGABLE) { Log.d(Constants.LOG_TAG, "I am going to skip this, but if I didn't, the text would be: " + ((TextView) v).getText().toString()); } if (existing_text.isEmpty() && v.getId() == android.R.id.title) { if (Constants.IS_LOGGABLE) { Log.d(Constants.LOG_TAG, "I was going to skip this, but the existing text was empty, and I need something."); } } else { continue; } } if (v instanceof TextView) { TextView tv = (TextView) v; if (tv.getText().toString() == "..." || tv.getText().toString() == "" || isInteger(tv.getText().toString()) || tv.getText().toString().trim().equalsIgnoreCase(existing_text)) { if (Constants.IS_LOGGABLE) { Log.d(Constants.LOG_TAG, "Text is: " + tv.getText().toString() + " but I am going to skip this"); } continue; } text += tv.getText().toString() + "\n"; if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, tv.getText().toString()); } } if (v instanceof ViewGroup) { text += dumpViewGroup(depth + 1, (ViewGroup) v, existing_text); } } return text; }