Example usage for android.widget TableRow getChildCount

List of usage examples for android.widget TableRow getChildCount

Introduction

In this page you can find the example usage for android.widget TableRow getChildCount.

Prototype

public int getChildCount() 

Source Link

Document

Returns the number of children in the group.

Usage

From source file:universe.constellation.orion.viewer.OrionViewerActivity.java

public void initCropScreen() {
    TableLayout cropTable = (TableLayout) findMyViewById(R.id.crop_borders);

    getSubscriptionManager().addDocListeners(new DocumentViewAdapter() {
        @Override/* w  ww.ja  v a  2  s  . c  o  m*/
        public void documentOpened(Controller controller) {
            updateCrops();
        }
    });

    for (int i = 0; i < cropTable.getChildCount(); i++) {
        TableRow row = (TableRow) cropTable.getChildAt(i);
        row.findViewById(R.id.crop_plus);

        TextView valueView = (TextView) row.findViewById(R.id.crop_value);
        ImageButton plus = (ImageButton) row.findViewById(R.id.crop_plus);
        ImageButton minus = (ImageButton) row.findViewById(R.id.crop_minus);
        linkCropButtonsAndText(minus, plus, valueView, i);
    }

    //even cropping
    int index = 4;
    final TableLayout cropTable2 = (TableLayout) findMyViewById(R.id.crop_borders_even);
    for (int i = 0; i < cropTable2.getChildCount(); i++) {
        View child = cropTable2.getChildAt(i);
        if (child instanceof TableRow) {
            TableRow row = (TableRow) child;
            row.findViewById(R.id.crop_plus);
            TextView valueView = (TextView) row.findViewById(R.id.crop_value);
            ImageButton plus = (ImageButton) row.findViewById(R.id.crop_plus);
            ImageButton minus = (ImageButton) row.findViewById(R.id.crop_minus);
            linkCropButtonsAndText(minus, plus, valueView, index);
            index++;
            for (int j = 0; j < row.getChildCount(); j++) {
                View v = row.getChildAt(j);
                v.setEnabled(false);
            }
        }
    }

    final ImageButton switchEven = (ImageButton) findMyViewById(R.id.crop_even_button);
    if (switchEven != null) {
        final ViewAnimator cropAnim = (ViewAnimator) findMyViewById(R.id.crop_animator);
        switchEven.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                cropAnim.setDisplayedChild((cropAnim.getDisplayedChild() + 1) % 2);
                switchEven.setImageResource(
                        cropAnim.getDisplayedChild() == 0 ? R.drawable.next : R.drawable.prev);
            }
        });
    }

    final CheckBox checkBox = (CheckBox) findMyViewById(R.id.crop_even_flag);
    checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            for (int i = 0; i < cropTable2.getChildCount(); i++) {
                View child = cropTable2.getChildAt(i);
                if (child instanceof TableRow) {
                    TableRow row = (TableRow) child;
                    for (int j = 0; j < row.getChildCount(); j++) {
                        View rowChild = row.getChildAt(j);
                        rowChild.setEnabled(isChecked);
                    }
                }
            }
        }
    });

    //        if (Device.Info.NOOK2) {
    //            TextView tv = (TextView) findMyViewById(R.id.navigation_title);
    //            int color = tv.getTextColors().getDefaultColor();
    //            checkBox.setTextColor(color);
    //        }

    ImageButton preview = (ImageButton) findMyViewById(R.id.crop_preview);
    preview.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            onApplyAction();
            controller.changeMargins(cropBorders[0], cropBorders[2], cropBorders[1], cropBorders[3],
                    checkBox.isChecked(), cropBorders[4], cropBorders[5]);
        }
    });

    ImageButton close = (ImageButton) findMyViewById(R.id.crop_close);
    close.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            //main menu
            onAnimatorCancel();
            //reset if canceled
            updateCrops();
        }
    });
}