List of usage examples for android.view ViewGroup getChildAt
public View getChildAt(int index)
From source file:mobi.cangol.mobile.navigation.SlidingMenuLayout.java
public void attachToActivity(Activity activity, boolean isFloatActionBarEnabled) { // get the window background TypedArray a = activity.getTheme().obtainStyledAttributes(new int[] { android.R.attr.windowBackground }); int background = a.getResourceId(0, 0); a.recycle();//from w ww .ja v a2 s .c om this.isFloatActionBarEnabled = isFloatActionBarEnabled; if (isFloatActionBarEnabled) { ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView(); ViewGroup decorChild = (ViewGroup) decor.getChildAt(0); if (decorChild.getBackground() != null) { this.setBackgroundDrawable(decorChild.getBackground()); decorChild.setBackgroundDrawable(null); } else { if (this.getBackground() == null) this.setBackgroundResource(background); } decor.removeView(decorChild); decor.addView(this.getRootView(), 0); getContentView().addView(decorChild); } else { ViewGroup contentParent = (ViewGroup) activity.findViewById(android.R.id.content); ViewGroup content = (ViewGroup) contentParent.getChildAt(0); contentParent.removeView(content); contentParent.addView(this, 0); getContentView().addView(content); } }
From source file:com.df.app.carsChecked.BasicInfoLayout.java
private View findView(ViewGroup viewGroup, String tag) { View view = null;//from w w w.j a va 2 s . c o m for (int i = 0; i < viewGroup.getChildCount(); i++) { view = viewGroup.getChildAt(i); if (view instanceof ViewGroup) { view = findView((ViewGroup) view, tag); if (tag.equals(view.getTag())) { return view; } } else { if (tag.equals(view.getTag())) { return view; } } } return view; }
From source file:com.secbro.qark.customintent.CreateCustomIntentActivity.java
private ArrayList<String> findAllValues(ArrayList<String> values, ViewGroup viewGroup) { int count = viewGroup.getChildCount(); for (int i = 0; i < count; i++) { View view = viewGroup.getChildAt(i); if (view instanceof ViewGroup) findAllValues(values, (ViewGroup) view); else if (view instanceof EditText) { EditText edittext = (EditText) view; if (edittext.getTag() != null && edittext.getTag().toString().equals("value_field")) { values.add(edittext.getText().toString()); }/*w w w.j av a2 s .com*/ } } return values; }
From source file:com.learn.mobile.customview.henrytao.SmoothCollapsingToolbarLayout.java
protected Toolbar getToolbar() { if (vToolbar == null) { int i = 0; ViewGroup parent = (ViewGroup) getParent(); View child;/*from w ww .j av a2 s. c om*/ for (int z = parent.getChildCount(); i < z; i++) { child = parent.getChildAt(i); if (child instanceof Toolbar) { vToolbar = (Toolbar) child; break; } } if (vToolbar == null) { throw new IllegalStateException("Must have Toolbar"); } } return vToolbar; }
From source file:com.secbro.qark.customintent.CreateCustomIntentActivity.java
private ArrayList<String> findAllKeys(ArrayList<String> keys, ViewGroup viewGroup) { int count = viewGroup.getChildCount(); for (int i = 0; i < count; i++) { View view = viewGroup.getChildAt(i); if (view instanceof ViewGroup) findAllKeys(keys, (ViewGroup) view); else if (view instanceof TextView) { TextView textview = (TextView) view; // if (!textview.getText().toString().equals(getResources().getString(R.string.intent_extras_key)) && // !textview.getText().toString().equals(getResources().getString(R.string.intent_extras_value)) && // !textview.getTag().toString().equals("value_field")) { if (textview.getTag() != null && textview.getTag().toString().equals("key_field")) { keys.add(textview.getText().toString()); }/*w w w . j a va 2 s . c o m*/ } } return keys; }
From source file:individual.leobert.calendar.CalendarLayout.java
private boolean isScroll(ViewGroup view2) { View fistChildView = view2.getChildAt(0); if (fistChildView == null) { return false; }/*from w ww . j a va 2 s . c o m*/ if (view2 instanceof ListView) { AbsListView list = (AbsListView) view2; if (fistChildView.getTop() != 0) { return true; } else { if (list.getPositionForView(fistChildView) != 0) { return true; } } } return false; }
From source file:com.calciumion.widget.BasePagerAdapter.java
@Override public final void finishUpdate(ViewGroup container) { ArrayList<View> recycledViews = new ArrayList<View>(); // Remove views backing destroyed items from the specified container, // and queue them for recycling. for (int i = 0; destroyedItems.size() > 0 && i < container.getChildCount(); i++) { View v = container.getChildAt(i); Iterator<Object> it = destroyedItems.iterator(); while (it.hasNext()) { if (isViewFromObject(v, it.next())) { container.removeView(v); recycledViews.add(v);//from www.j av a2 s.c o m it.remove(); break; } } } // Render views and attach them to the container. Page views are reused // whenever possible. for (Object instantiatedItem : instantiatedItems) { View convertView = null; if (recycledViews.size() > 0) convertView = recycledViews.remove(0); convertView = getView(instantiatedItem, convertView, container); convertView.setTag(instantiatedItem); container.addView(convertView); } instantiatedItems.clear(); recycledViews.clear(); }
From source file:mobi.cangol.mobile.navigation.DrawerMenuLayout.java
private void fitDecorChild(View view) { ViewGroup contentView = (ViewGroup) view.findViewById(R.id.actionbar_content_view); if (contentView != null) { ViewGroup decorChild = (ViewGroup) contentView.getChildAt(0); if (decorChild != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { WindowManager manager = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) decorChild.getLayoutParams(); switch (manager.getDefaultDisplay().getRotation()) { case Surface.ROTATION_90: layoutParams.rightMargin = 0; break; case Surface.ROTATION_180: layoutParams.topMargin = 0; break; case Surface.ROTATION_270: layoutParams.leftMargin = 0; break; default: layoutParams.bottomMargin = 0; }/*from ww w.ja v a2s .c o m*/ decorChild.setLayoutParams(layoutParams); } } } }
From source file:info.tellmetime.DaydreamService.java
private void inflateMinutesIndicators() { FrameLayout minutesLayout = (FrameLayout) findViewById(R.id.minutes_indicators); minutesLayout.removeAllViews();/*from w ww.j a v a 2s .co m*/ LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); final boolean isLandscape = getResources() .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; inflater.inflate(isLandscape ? R.layout.minutes_land : R.layout.minutes_portrait, minutesLayout); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, isLandscape ? FrameLayout.LayoutParams.MATCH_PARENT : FrameLayout.LayoutParams.WRAP_CONTENT); if (!isLandscape) { layoutParams.addRule(RelativeLayout.BELOW, R.id.clock); layoutParams.topMargin = (int) -TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mMinutesSize / 3, getResources().getDisplayMetrics()); } minutesLayout.setLayoutParams(layoutParams); Typeface mTypefaceBold = Typeface.createFromAsset(getAssets(), "Roboto-BoldCondensed.ttf"); ViewGroup minutesDots = (ViewGroup) findViewById(R.id.minutes_dots); for (int i = 0; i < minutesDots.getChildCount(); i++) { TextView m = (TextView) minutesDots.getChildAt(i); m.setTypeface(mTypefaceBold); m.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mMinutesSize); m.setTextColor(mBacklightColor); m.setShadowLayer(mShorterEdge / 200 * mDensity, 0, 0, mBacklightColor); } }
From source file:com.wagos.calendarcard.RecyclePagerAdapter.java
@Override public final void finishUpdate(ViewGroup container) { ArrayList<View> recycledViews = new ArrayList<>(); // Remove views backing destroyed items from the specified container, // and queue them for recycling. for (int i = 0; destroyedItems.size() > 0 && i < container.getChildCount(); i++) { View v = container.getChildAt(i); Iterator<Object> it = destroyedItems.iterator(); while (it.hasNext()) { if (isViewFromObject(v, it.next())) { container.removeView(v); recycledViews.add(v);// w w w .j a va2 s . c om it.remove(); break; } } } // Render views and attach them to the container. Page views are reused // whenever possible. for (Object instantiatedItem : instantiatedItems) { View convertView = null; if (recycledViews.size() > 0) convertView = recycledViews.remove(0); if (convertView != null) { // Re-add existing view before rendering so that we can make change inside getView() container.addView(convertView); convertView = getView(instantiatedItem, convertView, container); } else { convertView = getView(instantiatedItem, null, container); container.addView(convertView); } // Set another tag id to not break ViewHolder pattern convertView.setTag(R.id.view_data, instantiatedItem); } instantiatedItems.clear(); recycledViews.clear(); }