List of usage examples for android.view ViewGroup getChildCount
public int getChildCount()
From source file:com.mfh.comna.api.widgets.PagerSlidingTabStrip.java
/** * ViewPager//from w w w.ja va 2 s. co m * * @param viewPager * ViewPager */ public void setViewPager(ViewPager viewPager) { if (disableViewPager) return; this.viewPager = viewPager; 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.xnf.henghenghui.ui.view.PagerSlidingTabStrip.java
/** * ViewPager//from w w w. j a va2 s .co m * * @param viewPager * ViewPager */ public void setViewPager(ViewPager viewPager) { // if (disableViewPager) // return; this.viewPager = viewPager; this.viewPager.setOnPageChangeListener(new 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.cicada.startup.common.ui.view.indicator.ViewPagerIndicator.java
/** * ViewPager//from w w w . ja v a2 s .c o m * * @param viewPager ViewPager */ public void setViewPager(ViewPager viewPager) { if (disableViewPager) return; this.viewPager = viewPager; this.viewPager.setOnPageChangeListener(new 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.lgh.tool.myview.PagerSlidingTabStrip.java
/** * ?TAB/*from ww w. j a v a 2 s . co m*/ */ private void selectedTab(int newSelectedTabPosition) { ViewGroup tabsLayout = getTabsLayout(); if (newSelectedTabPosition > -1 && tabsLayout != null && newSelectedTabPosition < tabsLayout.getChildCount()) { for (int w = 0, size = tabsLayout.getChildCount(); w < size; w++) { View tabView = tabsLayout.getChildAt(w); tabView.setSelected(w == newSelectedTabPosition); } } }
From source file:com.mfh.litecashier.ui.widget.TopSlidingTabStrip.java
/** * ViewPager//from ww w. ja v a2 s . c o m * * @param viewPager * ViewPager */ public void setViewPager(ViewPager viewPager) { if (disableViewPager) return; this.viewPager = viewPager; this.viewPager.addOnPageChangeListener(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:android.databinding.ViewDataBinding.java
private static int findLastMatching(ViewGroup viewGroup, int firstIncludedIndex) { final View firstView = viewGroup.getChildAt(firstIncludedIndex); final String firstViewTag = (String) firstView.getTag(); final String tagBase = firstViewTag.substring(0, firstViewTag.length() - 1); // don't include the "0" final int tagSequenceIndex = tagBase.length(); final int count = viewGroup.getChildCount(); int max = firstIncludedIndex; for (int i = firstIncludedIndex + 1; i < count; i++) { final View view = viewGroup.getChildAt(i); final String tag = (String) view.getTag(); if (tag != null && tag.startsWith(tagBase)) { if (tag.length() == firstViewTag.length() && tag.charAt(tag.length() - 1) == '0') { return max; // Found another instance of the include }//from w w w . j a va2 s . co m if (isNumeric(tag, tagSequenceIndex)) { max = i; } } } return max; }
From source file:com.taobao.weex.ui.component.WXVContainer.java
/** * transverse view tree, and recycle wximageview in container * *///from w w w. j a va 2 s . c o m private void doViewTreeRecycleImageView(ViewGroup viewGroup, boolean isRelease) { int count = viewGroup.getChildCount(); for (int i = 0; i < count; i++) { View view = viewGroup.getChildAt(i); if (view instanceof WXImageView) { if (isRelease) { ((WXImageView) view).autoReleaseImage(); } else { ((WXImageView) view).autoRecoverImage(); } } else if (view instanceof ViewGroup) { doViewTreeRecycleImageView((ViewGroup) view, isRelease); } } }
From source file:connect.app.com.connect.calendar.DayPickerView.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public DayPickerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); // final TypedArray a = context.obtainStyledAttributes(attrs, // R.styleable.CalendarView, defStyleAttr, defStyleRes); ////from w ww . j a v a2 s .c o m // final int firstDayOfWeek = a.getInt(R.styleable.CalendarView_firstDayOfWeek, // LocaleData.get(Locale.getDefault()).firstDayOfWeek); final int firstDayOfWeek = 1; // // final String minDate = a.getString(R.styleable.CalendarView_minDate); final String minDate = null; // final String maxDate = a.getString(R.styleable.CalendarView_maxDate); final String maxDate = null; // // final int monthTextAppearanceResId = a.getResourceId( // R.styleable.CalendarView_monthTextAppearance, // R.style.TextAppearance_Material_Widget_Calendar_Month); // final int dayOfWeekTextAppearanceResId = a.getResourceId( // R.styleable.CalendarView_weekDayTextAppearance, // R.style.TextAppearance_Material_Widget_Calendar_DayOfWeek); // final int dayTextAppearanceResId = a.getResourceId( // R.styleable.CalendarView_dateTextAppearance, // R.style.TextAppearance_Material_Widget_Calendar_Day); // // final ColorStateList daySelectorColor = a.getColorStateList( // R.styleable.CalendarView_daySelectorColor); // // a.recycle(); // Set up adapter. mAdapter = new DayPickerPagerAdapter(context, R.layout.layout_test, com.retrofit.R.id.scrollView); // mAdapter.setMonthTextAppearance(monthTextAppearanceResId); // mAdapter.setDayOfWeekTextAppearance(dayOfWeekTextAppearanceResId); // mAdapter.setDayTextAppearance(dayTextAppearanceResId); // mAdapter.setDaySelectorColor(daySelectorColor); 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.setOnPageChangeListener(mOnPageChangedListener); // Proxy the month text color into the previous and next buttons. // if (monthTextAppearanceResId != 0) { // final TypedArray ta = mContext.obtainStyledAttributes(null, // ATTRS_TEXT_COLOR, 0, monthTextAppearanceResId); // final ColorStateList monthColor = ta.getColorStateList(0); // if (monthColor != null) { // mPrevButton.setImageTintList(monthColor); // mNextButton.setImageTintList(monthColor); // } // ta.recycle(); // } // Set up min and max dates. final Calendar tempDate = Calendar.getInstance(); if (!CalendarView.parseDate(minDate, tempDate)) { tempDate.set(DEFAULT_START_YEAR, Calendar.JANUARY, 1); } final long minDateMillis = tempDate.getTimeInMillis(); if (!CalendarView.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:cn.wyx.android.swipeback.swipe.SwipeBackLayout.java
/** * Find out the scrollable child view from a ViewGroup. * * @param viewGroup//from w ww.java 2s . co m */ private void findScrollView(ViewGroup viewGroup) { scrollChild = viewGroup; if (viewGroup.getChildCount() > 0) { int count = viewGroup.getChildCount(); View child; for (int i = 0; i < count; i++) { child = viewGroup.getChildAt(i); if (child instanceof AbsListView || child instanceof ScrollView || child instanceof ViewPager || child instanceof WebView || child instanceof RecyclerView) { scrollChild = child; return; } } } }
From source file:com.normalexception.app.rx8club.fragment.pm.PrivateMessageInboxFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onCreate(savedInstanceState); MainApplication.setState(AppState.State.PMINBOX, this); if (TimeoutFactory.getInstance().checkTimeout(this)) { pmlist = new ArrayList<PMModel>(); lv = (ListView) view.findViewById(R.id.mainlistview); ViewGroup header = (ViewGroup) getActivity().getLayoutInflater().inflate(R.layout.view_inbox_header, lv, false);/* ww w.ja va 2s. c om*/ InboxHeaderListener ihl = new InboxHeaderListener(); View v = null; for (int i = 0; i < header.getChildCount(); i++) { v = header.getChildAt(i); if (v instanceof Button) v.setOnClickListener(ihl); } lv.addHeaderView(header); Log.v(TAG, "PM Activity Started"); if (savedInstanceState == null || (pmva == null || pmva.getCount() == 0)) constructView(); else { updateList(); } } }