Example usage for android.view ViewGroup getChildAt

List of usage examples for android.view ViewGroup getChildAt

Introduction

In this page you can find the example usage for android.view ViewGroup getChildAt.

Prototype

public View getChildAt(int index) 

Source Link

Document

Returns the view at the specified position in the group.

Usage

From source file:com.tapfortap.phonegap.TapForTapPhoneGapPlugin.java

private void getRootLayout(final Runnable r) {
    (cordova.getActivity()).runOnUiThread(new Runnable() {
        @Override/*  w w  w  . ja v  a 2s  .co m*/
        public void run() {
            if (rootLayout == null) {
                ViewGroup viewGroup = (ViewGroup) (cordova.getActivity()).findViewById(android.R.id.content);
                rootLayout = (LinearLayout) viewGroup.getChildAt(0);
            }
            if (r != null)
                r.run();
        }
    });
}

From source file:com.dante.girl.lib.MorphFabToDialog.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override//from  www  . j  ava2s . co  m
public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues,
        final TransitionValues endValues) {
    Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues);
    if (startValues == null || endValues == null || changeBounds == null) {
        return null;
    }

    Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR);
    Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS);
    Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR);
    Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS);

    if (startColor == null || startCornerRadius == null || endColor == null || endCornerRadius == null) {
        return null;
    }

    MorphDrawable background = new MorphDrawable(startColor, startCornerRadius);
    endValues.view.setBackground(background);

    Animator color = ObjectAnimator.ofArgb(background, MorphDrawable.COLOR, endColor);
    Animator corners = ObjectAnimator.ofFloat(background, MorphDrawable.CORNER_RADIUS, endCornerRadius);

    // ease in the dialog's child views (slide up & fade_fast in)
    if (endValues.view instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) endValues.view;
        float offset = vg.getHeight() / 3;
        for (int i = 0; i < vg.getChildCount(); i++) {
            View v = vg.getChildAt(i);
            v.setTranslationY(offset);
            v.setAlpha(0f);
            v.animate().alpha(1f).translationY(0f).setDuration(150).setStartDelay(150).setInterpolator(
                    AnimationUtils.loadInterpolator(vg.getContext(), android.R.interpolator.fast_out_slow_in));
            offset *= 1.8f;
        }
    }

    AnimatorSet transition = new AnimatorSet();
    transition.playTogether(changeBounds, corners, color);
    transition.setDuration(300);
    transition.setInterpolator(
            AnimationUtils.loadInterpolator(sceneRoot.getContext(), android.R.interpolator.fast_out_slow_in));
    return transition;
}

From source file:com.example.android.animationsdemo.BoardFragment.java

public void addItem(View view) {

    LayoutInflater inflater = LayoutInflater.from(getActivity());
    View newCard = inflater.inflate(R.layout.new_card_layout, null, false);
    newCard.setTag("newCard");
    ViewGroup parentCol = (ViewGroup) view.getParent();
    ViewGroup svCol = (ViewGroup) parentCol.getChildAt(parentCol.getChildCount() - 1);
    ViewGroup containerCol = (ViewGroup) svCol.getChildAt(0);
    View check = containerCol.findViewWithTag("newCard");
    if (check == null)
        containerCol.addView(newCard, 0);
    else// w  w  w  .  j  a v a 2  s .c o  m
        containerCol.removeView(check);
    ImageView save = (ImageView) newCard.findViewById(R.id.saveNewCard);
    final EditText title = (EditText) newCard.findViewById(R.id.newCardTitle);
    save.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view1) {
            if (isEmpty(title))
                Toast.makeText(context, "Please enter a title", Toast.LENGTH_SHORT).show();
            else {
                query = "";
                pager.getAdapter().notifyDataSetChanged();
                InputMethodManager imm = (InputMethodManager) context
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(title.getWindowToken(), 0);
            } //
        }
    });
}

From source file:com.caij.codehub.ui.transitions.MorphFabToDialog.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override/*from   ww w.j a  v  a2 s.  c o m*/
public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues,
        final TransitionValues endValues) {
    Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues);
    if (startValues == null || endValues == null || changeBounds == null) {
        return null;
    }

    Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR);
    Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS);
    Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR);
    Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS);

    if (startColor == null || startCornerRadius == null || endColor == null || endCornerRadius == null) {
        return null;
    }

    MorphDrawable background = new MorphDrawable(startColor, startCornerRadius);
    endValues.view.setBackground(background);

    Animator color = ObjectAnimator.ofArgb(background, background.COLOR, endColor);
    Animator corners = ObjectAnimator.ofFloat(background, background.CORNER_RADIUS, endCornerRadius);

    // ease in the dialog's child views (slide up & fade in)
    if (endValues.view instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) endValues.view;
        float offset = vg.getHeight() / 3;
        for (int i = 0; i < vg.getChildCount(); i++) {
            View v = vg.getChildAt(i);
            v.setTranslationY(offset);
            v.setAlpha(0f);
            v.animate().alpha(1f).translationY(0f).setDuration(150).setStartDelay(150).setInterpolator(
                    AnimationUtils.loadInterpolator(vg.getContext(), android.R.interpolator.fast_out_slow_in));
            offset *= 1.8f;
        }
    }

    AnimatorSet transition = new AnimatorSet();
    transition.playTogether(changeBounds, corners, color);
    transition.setDuration(300);
    transition.setInterpolator(
            AnimationUtils.loadInterpolator(sceneRoot.getContext(), android.R.interpolator.fast_out_slow_in));
    return transition;
}

From source file:com.josecalles.porridge.transitions.MorphFabToDialog.java

@Override
public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues,
        final TransitionValues endValues) {
    Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues);
    if (startValues == null || endValues == null || changeBounds == null) {
        return null;
    }/*from ww  w  .j  av  a  2  s  .c  o m*/

    Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR);
    Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS);
    Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR);
    Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS);

    if (startColor == null || startCornerRadius == null || endColor == null || endCornerRadius == null) {
        return null;
    }

    MorphDrawable background = new MorphDrawable(startColor, startCornerRadius);
    endValues.view.setBackground(background);

    Animator color = ObjectAnimator.ofArgb(background, background.COLOR, endColor);
    Animator corners = ObjectAnimator.ofFloat(background, background.CORNER_RADIUS, endCornerRadius);

    // ease in the dialog's child views (slide up & fade in)
    if (endValues.view instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) endValues.view;
        float offset = vg.getHeight() / 3;
        for (int i = 0; i < vg.getChildCount(); i++) {
            View v = vg.getChildAt(i);
            v.setTranslationY(offset);
            v.setAlpha(0f);
            v.animate().alpha(1f).translationY(0f).setDuration(150).setStartDelay(150).setInterpolator(
                    AnimationUtils.loadInterpolator(vg.getContext(), android.R.interpolator.fast_out_slow_in));
            offset *= 1.8f;
        }
    }

    AnimatorSet transition = new AnimatorSet();
    transition.playTogether(changeBounds, corners, color);
    transition.setDuration(300);
    transition.setInterpolator(
            AnimationUtils.loadInterpolator(sceneRoot.getContext(), android.R.interpolator.fast_out_slow_in));
    return transition;
}

From source file:io.romain.passport.ui.transitions.MorphFabToDialog.java

@Override
public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues,
        final TransitionValues endValues) {
    Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues);
    if (startValues == null || endValues == null || changeBounds == null) {
        return null;
    }//from ww w. ja  v a 2 s .co  m

    Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR);
    Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS);
    Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR);
    Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS);

    if (startColor == null || startCornerRadius == null || endColor == null || endCornerRadius == null) {
        return null;
    }

    MorphDrawable background = new MorphDrawable(startColor, startCornerRadius);
    endValues.view.setBackground(background);

    Animator color = ObjectAnimator.ofArgb(background, MorphDrawable.COLOR, endColor);
    Animator corners = ObjectAnimator.ofFloat(background, MorphDrawable.CORNER_RADIUS, endCornerRadius);

    // ease in the dialog's child views (slide up & fade in)
    if (endValues.view instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) endValues.view;
        float offset = vg.getHeight() / 3;
        for (int i = 0; i < vg.getChildCount(); i++) {
            View v = vg.getChildAt(i);
            v.setTranslationY(offset);
            v.setAlpha(0f);
            v.animate().alpha(1f).translationY(0f).setDuration(150).setStartDelay(150)
                    .setInterpolator(AnimUtils.getFastOutSlowInInterpolator(vg.getContext()));
            offset *= 1.8f;
        }
    }

    AnimatorSet transition = new AnimatorSet();
    transition.playTogether(changeBounds, corners, color);
    transition.setDuration(300);
    transition.setInterpolator(AnimUtils.getFastOutSlowInInterpolator(sceneRoot.getContext()));
    return transition;
}

From source file:com.geecko.QuickLyric.AboutActivity.java

private void setupDemoScreen() {
    ViewGroup rootView = (ViewGroup) findViewById(android.R.id.content).getRootView();
    getLayoutInflater().inflate(R.layout.tutorial_view, (ViewGroup) rootView.getChildAt(0));
    final ViewPager pager = (ViewPager) findViewById(R.id.pager);
    CirclePageIndicator indicator = (CirclePageIndicator) findViewById(R.id.indicator);
    final IntroScreenSlidePagerAdapter pagerAdapter = new IntroScreenSlidePagerAdapter(getFragmentManager(),
            this);
    pager.setAdapter(pagerAdapter);/* ww w .  java  2  s.c  o  m*/
    pager.addOnPageChangeListener(pagerAdapter);
    indicator.setViewPager(pager);
    pager.setCurrentItem(pagerAdapter.rightToLeft ? pagerAdapter.getCount() - 1 : 0);
    indicator.setOnPageChangeListener(pagerAdapter);
    Button skipButton = (Button) rootView.findViewById(R.id.pager_button);
    ImageButton arrowButton = (ImageButton) rootView.findViewById(R.id.pager_arrow);
    skipButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT)
                pagerAdapter.exitAction();
            else
                pager.setCurrentItem(pagerAdapter.getCount() - 1);
        }
    });
    arrowButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            pagerAdapter.nextAction();
        }
    });
}

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   ww  w. j a  va2s.c o  m*/
            if (isNumeric(tag, tagSequenceIndex)) {
                max = i;
            }
        }
    }
    return max;
}

From source file:com.freshplanet.nativeExtensions.C2DMBroadcastReceiver.java

private boolean recurseGroup(Context context, ViewGroup gp) {
    final int count = gp.getChildCount();
    for (int i = 0; i < count; ++i) {
        if (gp.getChildAt(i) instanceof TextView) {
            final TextView text = (TextView) gp.getChildAt(i);
            final String szText = text.getText().toString();
            if (COLOR_SEARCH_RECURSE_TIP.equals(szText)) {
                notification_text_color = text.getTextColors().getDefaultColor();
                notification_text_size = text.getTextSize();
                DisplayMetrics metrics = new DisplayMetrics();
                WindowManager systemWM = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
                systemWM.getDefaultDisplay().getMetrics(metrics);
                notification_text_size /= metrics.scaledDensity;
                return true;
            }//from ww  w. j  a  va 2  s.c  o  m
        } else if (gp.getChildAt(i) instanceof ViewGroup)
            return recurseGroup((Context) context, (ViewGroup) gp.getChildAt(i));
    }
    return false;
}

From source file:com.vuze.android.remote.dialog.DialogFragmentSessionSettings.java

public void setGroupEnabled(ViewGroup viewGroup, boolean enabled) {
    for (int i = 0; i < viewGroup.getChildCount(); i++) {
        View view = viewGroup.getChildAt(i);
        view.setEnabled(enabled);/*w w  w.  j  a  v  a2 s. c  o  m*/
    }
}