Example usage for android.view ViewGroup getChildCount

List of usage examples for android.view ViewGroup getChildCount

Introduction

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

Prototype

public int getChildCount() 

Source Link

Document

Returns the number of children in the group.

Usage

From source file:com.oasisfeng.nevo.decorators.media.MediaPlayerDecorator.java

/** @return continue or not */
private boolean findClickable(final ViewGroup views, final Predicate<View> callback) {
    for (int i = 0; i < views.getChildCount(); i++) {
        final View view = views.getChildAt(i);
        if (view instanceof ViewGroup) {
            if (!findClickable((ViewGroup) view, callback))
                return false;
        } else if (view.hasOnClickListeners())
            if (!callback.apply(view))
                return false;
    }/* w w  w.j  a  va2 s .co m*/
    return true;
}

From source file:com.njlabs.amrita.aid.gpms.ui.PendingPassActivity.java

public void cancelPass(final View v) {
    String requestId = (String) v.getTag();
    ProgressBar progressBar = null;//from www  . j av a 2 s. c  o m
    ViewGroup row = (ViewGroup) v.getParent();
    for (int itemPos = 0; itemPos < row.getChildCount(); itemPos++) {
        View view = row.getChildAt(itemPos);
        if (view instanceof ProgressBar) {
            progressBar = (ProgressBar) view;
            break;
        }
    }

    if (progressBar != null) {
        progressBar.setVisibility(View.VISIBLE);
        v.setVisibility(View.GONE);
    }

    final ProgressBar finalProgressBar = progressBar;

    gpms.cancelPass(requestId, new SuccessResponse() {
        @Override
        public void onSuccess() {
            swipeRefreshLayout.setRefreshing(true);
            loadData();
            Snackbar.make(parentView, "Pass cancelled successfully.", Snackbar.LENGTH_LONG).show();

            Bundle bundle = new Bundle();
            bundle.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "GPMS");
            bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, "Cancel Pass");
            bundle.putString(FirebaseAnalytics.Param.CHARACTER,
                    gpms.getStudentName() + " - " + gpms.getStudentRollNo());
            tracker.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);
        }

        @Override
        public void onFailure(Throwable throwable) {
            Ln.e(throwable);
            if (finalProgressBar != null) {
                finalProgressBar.setVisibility(View.GONE);
                v.setVisibility(View.VISIBLE);
            }
            Snackbar.make(parentView, "An error occurred while cancelling your pass", Snackbar.LENGTH_LONG)
                    .show();
        }
    });
}

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 ww . j  a  v a2  s .c o m*/
        }
    }
    return values;
}

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. jav a2s .c o m
        }
    }
    return keys;
}

From source file:au.org.ala.fielddata.mobile.SurveyBuilder.java

private View getFirstNonLabelView(ViewGroup row) {
    int i;/*from w ww  .  ja v a2s.  c  om*/
    for (i = 0; i < row.getChildCount(); i++) {
        if (!(row.getChildAt(i) instanceof TextView)) {
            break;
        } else if (row.getChildAt(i) instanceof EditText) {
            break;
        }
    }
    return row.getChildAt(i);
}

From source file:kiv.janecekz.ma.ToneFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View root = inflater.inflate(R.layout.tone, container, false);
    RelativeLayout space = (RelativeLayout) root.findViewById(R.id.sunspace);
    space.setOnTouchListener(TouchControl.getInstance());

    circle = (ImageView) root.findViewById(R.id.circle);

    inAnim = TouchControl.getAnimation(TouchControl.ANIMATION_IN, 300);
    outAnim = TouchControl.getAnimation(TouchControl.ANIMATION_OUT, 300);

    input = (EditText) root.findViewById(R.id.tone_value_edit);
    input.setOnEditorActionListener(this);

    TextView sharp = (TextView) root.findViewById(R.id.sharp);
    sharp.setOnClickListener(this);

    ViewGroup defList = (ViewGroup) root.findViewById(R.id.tone_list);
    for (int i = 0; i < defList.getChildCount(); i++) {
        TextView v = (TextView) defList.getChildAt(i);
        v.setOnClickListener(this);
    }/* www. ja  v a 2  s. c  om*/
    return root;
}

From source file:gr.plushost.prototypeapp.widgets.LabelView.java

public void remove() {
    if (getParent() == null || _labelViewContainerID == -1) {
        return;/*from w w  w. j  a  v a  2 s  . c o m*/
    }

    ViewGroup frameContainer = (ViewGroup) getParent();
    assert (frameContainer.getChildCount() == 2);
    View target = frameContainer.getChildAt(0);

    ViewGroup parentContainer = (ViewGroup) frameContainer.getParent();
    int groupIndex = parentContainer.indexOfChild(frameContainer);
    if (frameContainer.getParent() instanceof RelativeLayout) {
        for (int i = 0; i < parentContainer.getChildCount(); i++) {
            if (i == groupIndex) {
                continue;
            }
            View view = parentContainer.getChildAt(i);
            RelativeLayout.LayoutParams para = (RelativeLayout.LayoutParams) view.getLayoutParams();
            for (int j = 0; j < para.getRules().length; j++) {
                if (para.getRules()[j] == _labelViewContainerID) {
                    para.getRules()[j] = target.getId();
                }
            }
            view.setLayoutParams(para);
        }
    }

    ViewGroup.LayoutParams frameLayoutParam = frameContainer.getLayoutParams();
    target.setLayoutParams(frameLayoutParam);
    parentContainer.removeViewAt(groupIndex);
    frameContainer.removeView(target);
    frameContainer.removeView(this);
    parentContainer.addView(target, groupIndex);
    _labelViewContainerID = -1;
}

From source file:org.kevoree.platform.android.boot.view.ManagerUI.java

/**
 * Call requestLayout() recursively on each child view
 * contained into this view if it has any. Otherwise
 * the call will only be made on the given view
 *
 * @param view a View object//  w  ww .  ja va  2s . c  om
 */
private void doRequestLayout(View view) {
    ViewGroup vg = null;
    if (view instanceof ViewGroup) {
        vg = (ViewGroup) view;
        for (int i = 0; i < vg.getChildCount(); i++) {
            doRequestLayout(vg.getChildAt(i));
        }

    } else {
        view.requestLayout();
    }
}

From source file:net.peterkuterna.android.apps.devoxxfrsched.ui.SearchActivity.java

@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);

    ViewGroup detailContainer = (ViewGroup) findViewById(R.id.fragment_container_search_detail);
    if (detailContainer != null && detailContainer.getChildCount() > 1) {
        findViewById(android.R.id.empty).setVisibility(View.GONE);
    }//from www  .  j av  a 2s  .  co  m
}

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/*from  www .  ja  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);
            } //
        }
    });
}