List of usage examples for android.view ViewGroup getChildCount
public int getChildCount()
From source file:com.tmall.wireless.tangram.ext.SwipeItemTouchListener.java
private View findCanScrollView(View v) { if (v instanceof ViewGroup) { ViewGroup target = (ViewGroup) v; if ((target instanceof UltraViewPager || target instanceof RecyclerView) && target.getVisibility() == View.VISIBLE) { return target; } else {//from ww w . j a v a 2 s. co m for (int i = 0; i < target.getChildCount(); ++i) { View view = findCanScrollView(target.getChildAt(i)); if (view != null) { return view; } } return null; } } else { return null; } }
From source file:com.aibasis.parent.widget.PagerSlidingTabStrip.java
/** * ?TAB/* ww w. j a v a 2 s . c o m*/ */ private 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.aibasis.parent.widget.PagerSlidingTabStrip.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); if (!allowWidthFull) return;//ww w .j a v a2s . c o m ViewGroup tabsLayout = getTabsLayout(); if (tabsLayout == null || tabsLayout.getMeasuredWidth() >= getMeasuredWidth()) return; if (tabsLayout.getChildCount() <= 0) return; if (tabViews == null) { tabViews = new ArrayList<View>(); } else { tabViews.clear(); } for (int w = 0; w < tabsLayout.getChildCount(); w++) { tabViews.add(tabsLayout.getChildAt(w)); } adjustChildWidthWithParent(tabViews, getMeasuredWidth() - tabsLayout.getPaddingLeft() - tabsLayout.getPaddingRight(), widthMeasureSpec, heightMeasureSpec); super.onMeasure(widthMeasureSpec, heightMeasureSpec); }
From source file:com.tr4android.support.extension.picker.date.DayPickerView.java
public DayPickerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DatePickerDialog, defStyleAttr, 0); //TODO: add default style res final int firstDayOfWeek = a.getInt(R.styleable.DatePickerDialog_firstDayOfWeek, Calendar.getInstance(Locale.getDefault()).getFirstDayOfWeek()); final String minDate = a.getString(R.styleable.DatePickerDialog_minDate); final String maxDate = a.getString(R.styleable.DatePickerDialog_maxDate); final int monthTextAppearanceResId = a.getResourceId(R.styleable.DatePickerDialog_monthTextAppearance, R.style.TextAppearance_Material_Widget_Calendar_Month); final int dayOfWeekTextAppearanceResId = a.getResourceId(R.styleable.DatePickerDialog_weekDayTextAppearance, R.style.TextAppearance_Material_Widget_Calendar_DayOfWeek); final int dayTextAppearanceResId = a.getResourceId(R.styleable.DatePickerDialog_dateTextAppearance, R.style.TextAppearance_Material_Widget_Calendar_Day); // Set up day selected color, if available. final ColorStateList daySelectorColor; if (a.hasValue(R.styleable.DatePickerDialog_daySelectorColor)) { daySelectorColor = a.getColorStateList(R.styleable.DatePickerDialog_daySelectorColor); } else {//w ww . j a va 2 s . c o m final TypedArray ta = context.obtainStyledAttributes(new int[] { R.attr.colorControlActivated }); daySelectorColor = ta.getColorStateList(0); ta.recycle(); } // Set up day highlight color, if available. final ColorStateList dayHighlightColor; if (a.hasValue(R.styleable.DatePickerDialog_dayHighlightColor)) { dayHighlightColor = a.getColorStateList(R.styleable.DatePickerDialog_dayHighlightColor); } else { final TypedArray ta = context.obtainStyledAttributes(new int[] { R.attr.colorControlHighlight }); dayHighlightColor = ta.getColorStateList(0); ta.recycle(); } a.recycle(); // Set up adapter. mAdapter = new DayPickerPagerAdapter(context, R.layout.day_picker_month_item_material, R.id.month_view); mAdapter.setMonthTextAppearance(monthTextAppearanceResId); mAdapter.setDayOfWeekTextAppearance(dayOfWeekTextAppearanceResId); mAdapter.setDayTextAppearance(dayTextAppearanceResId); mAdapter.setDaySelectorColor(daySelectorColor); mAdapter.setDayHighlightColor(dayHighlightColor); final LayoutInflater inflater = LayoutInflater.from(context); final ViewGroup content = (ViewGroup) inflater.inflate(DEFAULT_LAYOUT, this, false); // Transfer all children from content to here. while (content.getChildCount() > 0) { final View child = content.getChildAt(0); content.removeViewAt(0); addView(child); } mPrevButton = (ImageButton) findViewById(R.id.prev); mPrevButton.setOnClickListener(mOnClickListener); mNextButton = (ImageButton) findViewById(R.id.next); mNextButton.setOnClickListener(mOnClickListener); mViewPager = (ViewPager) findViewById(R.id.day_picker_view_pager); mViewPager.setAdapter(mAdapter); mViewPager.addOnPageChangeListener(mOnPageChangedListener); // Set up background of the previous and next buttons. ViewCompatUtils.setBackground(mPrevButton, PickerThemeUtils.getNavButtonBackground(context)); ViewCompatUtils.setBackground(mNextButton, PickerThemeUtils.getNavButtonBackground(context)); // Set up min and max dates. final Calendar tempDate = Calendar.getInstance(); if (!parseDate(minDate, tempDate)) { tempDate.set(DEFAULT_START_YEAR, Calendar.JANUARY, 1); } final long minDateMillis = tempDate.getTimeInMillis(); if (!parseDate(maxDate, tempDate)) { tempDate.set(DEFAULT_END_YEAR, Calendar.DECEMBER, 31); } final long maxDateMillis = tempDate.getTimeInMillis(); if (maxDateMillis < minDateMillis) { throw new IllegalArgumentException("maxDate must be >= minDate"); } final long setDateMillis = MathUtils.constrain(System.currentTimeMillis(), minDateMillis, maxDateMillis); setFirstDayOfWeek(firstDayOfWeek); setMinDate(minDateMillis); setMaxDate(maxDateMillis); setDate(setDateMillis, false); // Proxy selection callbacks to our own listener. mAdapter.setOnDaySelectedListener(new DayPickerPagerAdapter.OnDaySelectedListener() { @Override public void onDaySelected(DayPickerPagerAdapter adapter, Calendar day) { if (mOnDaySelectedListener != null) { mOnDaySelectedListener.onDaySelected(DayPickerView.this, day); } } }); }
From source file:com.yeahka.mach.android.widget.viewPager.PagerSlidingTabStrip.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (disableViewPager) return;//w w w . j ava2 s . c o m /* ? */ ViewGroup tabsLayout = getTabsLayout(); Log.d("drawable", "drawable=" + (slidingBlockDrawable == null)); if (tabsLayout != null && tabsLayout.getChildCount() > 0 && slidingBlockDrawable != null) { resetLayout(tabsLayout); 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); } } slidingBlockDrawable.setBounds((int) slidingBlockLeft, 0, (int) slidingBlockRight, getHeight()); slidingBlockDrawable.draw(canvas); currentTab.setBackgroundDrawable(slidingBlockDrawable); Log.d("drawable", "drawn"); } } }
From source file:com.cicada.startup.common.ui.view.indicator.ViewPagerIndicator.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); if (!allowWidthFull) { return;/*from ww w . j a v a 2 s. c o m*/ } setMeasuredDimension(getMeasuredWidth(), getMeasuredHeight() + slidingBlockHeight); ViewGroup tabsLayout = getTabsLayout(); if (tabsLayout == null || tabsLayout.getMeasuredWidth() >= getMeasuredWidth()) return; if (tabsLayout.getChildCount() <= 0) return; if (tabViews == null) { tabViews = new ArrayList<View>(); } else { tabViews.clear(); } for (int w = 0; w < tabsLayout.getChildCount(); w++) { tabViews.add(tabsLayout.getChildAt(w)); } adjustChildWidthWithParent(tabViews, getMeasuredWidth() - tabsLayout.getPaddingLeft() - tabsLayout.getPaddingRight(), widthMeasureSpec, heightMeasureSpec); super.onMeasure(widthMeasureSpec, heightMeasureSpec); }
From source file:com.pluscubed.velociraptor.settings.SettingsActivity.java
private void enableDisableAllChildren(boolean enable, ViewGroup viewgroup) { for (int i = 0; i < viewgroup.getChildCount(); i++) { View child = viewgroup.getChildAt(i); child.setEnabled(enable);/*from w ww.j av a 2 s .co m*/ if (child instanceof ViewGroup) { enableDisableAllChildren(enable, (ViewGroup) child); } } }
From source file:com.mfh.litecashier.ui.widget.TopSlidingTabStrip.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); if (!allowWidthFull) return;// www .ja v a 2 s. c om 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)); } adjustChildWidthWithParent(tabViews, getMeasuredWidth() - tabsLayout.getPaddingLeft() - tabsLayout.getPaddingRight(), widthMeasureSpec, heightMeasureSpec); super.onMeasure(widthMeasureSpec, heightMeasureSpec); }
From source file:me.xiaopan.psts.PagerSlidingTabStrip.java
private void setTabClickEvent() { ViewGroup tabViewGroup = getTabsLayout(); if (tabViewGroup != null && tabViewGroup.getChildCount() > 0) { //?tab?Pager for (int w = 0; w < tabViewGroup.getChildCount(); w++) { View itemView = tabViewGroup.getChildAt(w); itemView.setTag(w);/* ww w .j a v a2s . c o m*/ itemView.setOnClickListener(tabViewClickListener); itemView.setOnTouchListener(tabViewDoubleClickGestureDetector); } } }
From source file:com.ring.widget.PagerSlidingTabStrip.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (disableViewPager) return;//from w ww . j a v a2s. com /* ? */ ViewGroup tabsLayout = getTabsLayout(); int tabCount = tabsLayout.getChildCount(); if (tabsLayout == null || tabCount == 0) { return; } View currentTab = tabsLayout.getChildAt(currentPosition); if (currentTab == null) { return; } int height = getHeight(); 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 (slidingBlockDrawable != null) { // ? 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); } else { rectPaint.setColor(barColor); canvas.drawRect(slidingBlockLeft, height - barHeight, slidingBlockRight, height, rectPaint); rectPaint.setColor(underlineColor); canvas.drawRect(0, height - underLineHeight, tabsLayout.getWidth(), height, rectPaint); } if (isAllowDivider) { // draw divider dividerPaint.setColor(dividerColor); for (int i = 0; i < tabCount - 1; i++) { View tab = tabsLayout.getChildAt(i); canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint); } } }