Example usage for android.widget TableLayout getChildCount

List of usage examples for android.widget TableLayout getChildCount

Introduction

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

Prototype

public int getChildCount() 

Source Link

Document

Returns the number of children in the group.

Usage

From source file:com.retroteam.studio.retrostudio.MeasureEditor.java

/**
 * Assign a note visually and in the project.
 * @param view/*from  w  w w.j a v a  2 s . c  om*/
 */
private void paintNote(View view) {
    com.getbase.floatingactionbutton.FloatingActionButton ptool = (com.getbase.floatingactionbutton.FloatingActionButton) findViewById(
            R.id.pencilTool);
    ImageView iview = (ImageView) view;
    Drawable notestatus = iview.getDrawable();
    if (pencil) {
        if (notestatus.getConstantState().equals(ContextCompat
                .getDrawable(getApplicationContext(), R.drawable.note_filled).getConstantState())) {

            //blank all other notes in the column
            TableRow parent = (TableRow) iview.getParent();
            TableLayout layoutparent = (TableLayout) parent.getParent();
            int notedrawlen = layoutparent.getChildCount();
            for (int x = 0; x < notedrawlen; x++) {
                TableRow noterow = (TableRow) layoutparent.getChildAt(x);
                for (int i = 0; i < noterow.getChildCount(); i++) {
                    ImageView note = (ImageView) noterow.getChildAt(i);
                    if (note.getTag(R.id.TAG_COLUMN) == iview.getTag(R.id.TAG_COLUMN)) {
                        note.setImageDrawable(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.measure_outline));
                        for (int n = 0; n < filledNotes.size(); n++) {
                            int[] comp = filledNotes.get(n);
                            if (comp[0] == (int) note.getTag(R.id.TAG_ROW)
                                    && comp[1] == (int) note.getTag(R.id.TAG_COLUMN)) {
                                filledNotes.remove(n);
                            }
                        }
                    }
                }
            }
            //set the drawable
            iview.setImageDrawable(
                    ContextCompat.getDrawable(getApplicationContext(), R.drawable.measure_outline));
            filledNotes.remove(
                    new int[] { (int) iview.getTag(R.id.TAG_ROW), (int) iview.getTag(R.id.TAG_COLUMN) });

            // set the other notes to rests
            List<Integer> guiSNAPRange = (List<Integer>) iview.getTag(R.id.TAG_GUISNAPRANGE);
            for (int z = guiSNAPRange.get(0); z <= guiSNAPRange.get(guiSNAPRange.size() - 1); z++) {
                theproject.track(trackNum).measure(measureNum).replace(z, new Note(Note.REST, noteSUB));
            }
        } else {
            //blank all other notes in the column
            TableRow parent = (TableRow) iview.getParent();
            TableLayout layoutparent = (TableLayout) parent.getParent();
            int notedrawlen = layoutparent.getChildCount();
            for (int x = 0; x < notedrawlen; x++) {
                TableRow noterow = (TableRow) layoutparent.getChildAt(x);
                for (int i = 0; i < noterow.getChildCount(); i++) {
                    ImageView note = (ImageView) noterow.getChildAt(i);
                    if (note.getTag(R.id.TAG_COLUMN) == iview.getTag(R.id.TAG_COLUMN)) {
                        note.setImageDrawable(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.measure_outline));
                        for (int n = 0; n < filledNotes.size(); n++) {
                            int[] comp = filledNotes.get(n);
                            if (comp[0] == (int) note.getTag(R.id.TAG_ROW)
                                    && comp[1] == (int) note.getTag(R.id.TAG_COLUMN)) {
                                filledNotes.remove(n);
                            }
                        }
                    }
                }
            }
            //set the drawable
            iview.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.note_filled));
            filledNotes
                    .add(new int[] { (int) iview.getTag(R.id.TAG_ROW), (int) iview.getTag(R.id.TAG_COLUMN) });

            //set the note in the data structure
            double notetype = stringToNoteDouble((String) iview.getTag(R.id.TAG_NOTE));
            List<Integer> guiSNAPRange = (List<Integer>) iview.getTag(R.id.TAG_GUISNAPRANGE);
            for (int z = guiSNAPRange.get(0); z <= guiSNAPRange.get(guiSNAPRange.size() - 1); z++) {
                theproject.track(trackNum).measure(measureNum).replace(z, new Note(notetype, noteSUB));
            }
        }
    }
}

From source file:com.acceleratedio.pac_n_zoom.FindTagsActivity.java

private void dsply_tags() {

    TableLayout tbl_tag_lo = (TableLayout) findViewById(R.id.tl_tag);
    int tag_mbr = 0;
    int tag_nmbr = fil_tags.length;
    String lst_str = "";
    int row_mbr;//from w  w w  .  j ava 2 s .  c  o  m

    tbl_tag_lo.setAlpha(185);

    // - Find the search string
    srch_str = srch_str.trim();
    boolean flg_srch_tags = !srch_str.equals("");

    if (flg_srch_tags) {

        String[] srch_ary = srch_str.split("\\s* \\s*");
        srch_str = srch_ary[srch_ary.length - 1].toLowerCase();
    }

    // - Remove any current rows
    int row_nmbr = tbl_tag_lo.getChildCount();

    if (row_nmbr > 0)
        tbl_tag_lo.removeAllViews();

    for (row_mbr = 0; row_mbr < 4 && tag_mbr < tag_nmbr; row_mbr++) {

        TableRow tableRow = new TableRow(this);
        tableRow.setGravity(Gravity.CENTER);

        tableRow.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT,
                TableLayout.LayoutParams.MATCH_PARENT, 1.0f));

        for (int clm_mbr = 0; clm_mbr < 3; clm_mbr++) {

            Button btnTag = new Button(this);

            while (tag_mbr < tag_nmbr
                    && (fil_tags[tag_mbr].equals("") || fil_tags[tag_mbr].equalsIgnoreCase(lst_str)
                            || flg_srch_tags && !fil_tags[tag_mbr].toLowerCase().startsWith(srch_str))) {

                lst_str = fil_tags[tag_mbr];
                tag_mbr++;
            }

            if (tag_mbr >= tag_nmbr)
                break;

            lst_str = fil_tags[tag_mbr];
            btnTag.setText(fil_tags[tag_mbr++]);
            btnTag.setOnClickListener(this);

            btnTag.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,
                    TableRow.LayoutParams.MATCH_PARENT));

            tableRow.addView(btnTag);
        }

        tbl_tag_lo.addView(tableRow);
    }
}

From source file:at.ac.uniklu.mobile.sportal.DashboardUpcomingDatesFragment.java

private void adjustDateListHeight() {
    final TableLayout dateListTable = (TableLayout) getView().findViewById(R.id.dates);
    // post the action to the UI thread to defer execution until the view has been drawn
    dateListTable.post(new Runnable() {
        @Override//  w  ww.j av a2 s .com
        public void run() {
            // get first row
            View v = dateListTable.getChildAt(0);
            int entryHeight;
            if (v != null && (entryHeight = v.getMeasuredHeight()) > 0) {
                int numPossibleVisibleRows = dateListTable.getMeasuredHeight() / entryHeight;
                int numExisitingRows = Math.min(numPossibleVisibleRows, dateListTable.getChildCount());
                int numVisibleRows = Math.min(numExisitingRows, numPossibleVisibleRows);
                // remove rows that are outside the screen
                if (numExisitingRows > numVisibleRows) {
                    dateListTable.removeViews(numVisibleRows, numExisitingRows - numVisibleRows);
                }
                // toggle visibility of rows inside the screen
                for (int x = 0; x < numVisibleRows; x++) {
                    dateListTable.getChildAt(x).setVisibility(View.VISIBLE);
                }
            } else {
                Log.d(TAG, "cannot adjust list height");
            }
        }
    });
}

From source file:com.acceleratedio.pac_n_zoom.SaveAnmActivity.java

private void dsply_tags() {

    TableLayout tbl_tag_lo = (TableLayout) findViewById(R.id.tl_tgs);
    int tag_mbr = 0;
    int tag_nmbr = fil_tags.length;
    String lst_str = "";
    int row_mbr;/*from  w w  w.j a va 2s  .  c om*/

    tbl_tag_lo.setAlpha(185);

    // - Find the search string
    srch_str = srch_str.trim();
    boolean flg_srch_tags = !srch_str.equals("");

    if (flg_srch_tags) {

        String[] srch_ary = srch_str.split("\\s* \\s*");
        srch_str = srch_ary[srch_ary.length - 1].toLowerCase();
    }

    // - Remove any current rows
    int row_nmbr = tbl_tag_lo.getChildCount();

    if (row_nmbr > 0)
        tbl_tag_lo.removeAllViews();

    for (row_mbr = 0; tag_mbr < tag_nmbr; row_mbr++) {

        TableRow tableRow = new TableRow(this);
        tableRow.setGravity(Gravity.CENTER);

        tableRow.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT,
                TableLayout.LayoutParams.MATCH_PARENT, 1.0f));

        int clm_mbr;

        for (clm_mbr = 0; clm_mbr < 3; clm_mbr++) {

            Button btnTag = new Button(this);

            while (tag_mbr < tag_nmbr
                    && (fil_tags[tag_mbr].equals("") || fil_tags[tag_mbr].equalsIgnoreCase(lst_str)
                            || flg_srch_tags && !fil_tags[tag_mbr].toLowerCase().startsWith(srch_str))) {

                lst_str = fil_tags[tag_mbr];
                tag_mbr++;
            }

            if (tag_mbr >= tag_nmbr)
                break;

            lst_str = fil_tags[tag_mbr];
            btnTag.setText(fil_tags[tag_mbr++]);
            btnTag.setOnClickListener(this);

            btnTag.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,
                    TableRow.LayoutParams.MATCH_PARENT));

            tableRow.addView(btnTag);
        }

        if (clm_mbr > 0)
            tbl_tag_lo.addView(tableRow);
    }
}

From source file:com.cybrosys.currency.CurrencyMain.java

public void onStart() {
    super.onStart();
    getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
            WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
    linlaHeaderProgress = (LinearLayout) getView().findViewById(R.id.linlaHeaderProgress);
    imgvHead = (ImageView) getView().findViewById(R.id.imageHead);
    txtvHead = (TextView) getView().findViewById(R.id.textHead);
    lstvMainlistView = (ListView) getView().findViewById(R.id.listview);
    etxtText = (EditText) getView().findViewById(R.id.editText1);
    slide = (SlidingDrawer) getView().findViewById(R.id.SlidingDrawer);
    TableLayout tablePad = (TableLayout) getView().findViewById(R.id.tablone);
    int inPadCount = tablePad.getChildCount();
    for (int i = 0; i < inPadCount; i++) {
        View v = tablePad.getChildAt(i);
        if (v instanceof TableRow) {
            TableRow row = (TableRow) v;
            int rowCount = row.getChildCount();

            for (int r = 0; r < rowCount; r++) {
                View v2 = row.getChildAt(r);

                if (v2 instanceof Button) {
                    Button b = (Button) v2;
                    b.setOnClickListener(buttonpad);
                } else if (v2 instanceof TextView) {
                    TextView txtv = (TextView) v2;
                    txtv.setOnClickListener(null);
                }//from w w w.  j  av  a  2  s .  c  o  m
            }
        }
    }
    isFlag2 = true;
    Settings = getActivity().getSharedPreferences(strPREFERNAME, 0);
    for (int inI = 0; inI <= 5; inI++) {
        if (Settings.getString("val" + inI, "").equals("") && Settings.getString("CrnCode" + inI, "").equals("")
                && Settings.getString("flag" + inI, "").equals("")) {
            isFlag2 = false;
        }

    }
    if (isFlag2 == true) {
        Sharepreferences();
    } else {
        CustomListView();
        if (isConnection() == true) {
        } else {
            isFlag2 = true;
            isFlag = true;
            Toast.makeText(getActivity(), "No Internet Conection", Toast.LENGTH_LONG).show();
        }
    }
    SharedPreferences prefs = PalmCalcActivity.ctx.getSharedPreferences("UpdateTime", 0);
    lastUpdateTime = prefs.getLong("lastUpdateTime", 0);
    if ((lastUpdateTime) <= System.currentTimeMillis()) {
        lastUpdateTime = System.currentTimeMillis();
        SharedPreferences.Editor editors = prefs.edit();
        editors.putLong("lastUpdateTime", lastUpdateTime);
        editors.commit();
        if (isConnection() == true) {
            new BackProsess().execute(getActivity());
        }
    }
    etxtText.addTextChangedListener(textwach);
    aList = new ArrayList<HashMap<String, String>>();
    for (int InI = 0; InI < 5; InI++) {
        hm = new HashMap<String, String>();
        hm.put("flag", Integer.toString(fltFlags[InI]));
        if (InI != 5) {
            hm.put("cur", strCrnCode[InI].substring(0, 3));
        } else {
            hm.put("cur", strCrnCode[InI]);
        }
        aList.add(hm);
    }
    txtvHead.setText(strCrnCode[5]);
    imgvHead.setImageResource(fltFlags[5]);
    adapter = new ListAdapter1(getActivity(), aList);
    lstvMainlistView.setAdapter(adapter);
    lstvMainlistView.setOnItemClickListener(ListsingleClick);
    lstvMainlistView.setOnItemLongClickListener(ListLongClick);
    Decimalpoint();
    View vwMain = (View) getActivity().findViewById(R.id.idCurrencyMain);
    vwMain.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            slide.close();
            return true;
        }
    });
    etxtText.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!slide.isOpened()) {
                slide.open();
            }
        }
    });
    if (!Settings.getString("Input", "").equals("")) {
        calculation(Double.parseDouble(Settings.getString("Input", "")));
        etxtText.setText("");
        etxtText.setText(Settings.getString("Input", ""));
    } else {
        etxtText.setText(Settings.getString("Input", "1"));
    }
}

From source file:com.svpino.longhorn.artifacts.StockTileProcessor.java

@TargetApi(11)
private static int createStandardRow(Fragment fragment, TableLayout tableLayout, List<Stock> stocks,
        SparseArray<View> tiles, int height, int margin, int index, int row) {

    Stock stock1 = stocks.get(index);//from  w w w. j  av  a 2s.  c  o  m
    Stock stock2 = (index + 1 < stocks.size()) ? stocks.get(index + 1) : null;

    if (shouldUpdateTableRow(tableLayout, row, stock1, stock2)) {
        TableRow tableRow = new TableRow(fragment.getActivity());

        boolean shouldSpanFirstTile = row % 2 != 0;
        boolean shouldSpanSecondTile = !shouldSpanFirstTile;

        if (stock2 != null) {
            View tile1 = createTile(fragment, stock1, index, shouldSpanFirstTile);
            tiles.put(index, tile1);
            tableRow.addView(tile1, shouldSpanFirstTile ? getPartialSpannedLayoutParams(row, height, margin)
                    : getNotSpannedLayoutParams(row, height, margin));

            View tile2 = createTile(fragment, stock2, index + 1, shouldSpanSecondTile);
            tiles.put(index + 1, tile2);
            tableRow.addView(tile2,
                    shouldSpanSecondTile ? getLastPartialSpannedLayoutParams(row, height, margin)
                            : getLastNotSpannedLayoutParams(row, height, margin));
        } else {
            View tile1 = createTile(fragment, stock1, index, shouldSpanFirstTile);
            tiles.put(index, tile1);
            tableRow.addView(tile1, shouldSpanFirstTile ? getPartialSpannedLayoutParams(row, height, margin)
                    : getNotSpannedLayoutParams(row, height, margin));

            View tile2 = createTileForAddingNewStock(fragment);
            tiles.put(index + 1, tile2);
            tableRow.addView(tile2,
                    shouldSpanSecondTile ? getLastPartialSpannedLayoutParams(row, height, margin)
                            : getLastNotSpannedLayoutParams(row, height, margin));
        }

        if (row < tableLayout.getChildCount()) {
            tableLayout.removeViewAt(row);
        }

        tableLayout.addView(tableRow, row);
    }

    return index + 2;
}

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

public void updateCrops() {
    controller.getMargins(cropBorders);//from   ww w  .  j  a v a2 s .  c  o  m
    TableLayout cropTable = (TableLayout) findMyViewById(R.id.crop_borders);
    for (int i = 0; i < cropTable.getChildCount(); i++) {
        TableRow row = (TableRow) cropTable.getChildAt(i);
        TextView valueView = (TextView) row.findViewById(R.id.crop_value);
        valueView.setText(cropBorders[i] + "%");
    }

    TableLayout cropTable2 = (TableLayout) findMyViewById(R.id.crop_borders_even);
    int index = 4;
    for (int i = 0; i < cropTable2.getChildCount(); i++) {
        if (cropTable2.getChildAt(i) instanceof TableRow) {
            TableRow row = (TableRow) cropTable2.getChildAt(i);
            TextView valueView = (TextView) row.findViewById(R.id.crop_value);
            valueView.setText(cropBorders[index] + "%");
            index++;
        }
    }
    ((CheckBox) findMyViewById(R.id.crop_even_flag)).setChecked(controller.isEvenCropEnabled());
}

From source file:com.mobicage.rogerthat.plugins.messaging.ServiceMessageDetailActivity.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    mDisplayWidth = UIUtils.getDisplayWidth(this);

    if (!mSomebodyAnswered) {
        TableLayout tableLayout = (TableLayout) findViewById(R.id.buttons);
        for (int i = 0; i < tableLayout.getChildCount(); i++) {
            TableRow row = (TableRow) tableLayout.getChildAt(i);
            Button button = (Button) row.getChildAt(0);
            button.setWidth(mDisplayWidth - UIUtils.convertDipToPixels(this, 12));
        }//ww w  . j  a  v  a 2 s.  com
    }
}

From source file:reportsas.com.formulapp.Formulario.java

public int ObtenerRespuesta(LinearLayout contenedor, Pregunta Pregunta,
        ArrayList<PreguntaRespuesta> respuestaList) {
    PreguntaRespuesta result = new PreguntaRespuesta();
    int numRespuesta = 0;
    result.setIdPregunta(Pregunta.getIdPregunta());
    EditText resp;//from  w  w  w. j  av  a2 s  .c  o m
    TextView selectio;
    switch (Pregunta.getTipoPregunta()) {
    case 1:
        resp = (EditText) contenedor.findViewById(R.id.edtTexto);
        result.setItem(1);
        result.setRespuesta(resp.getText().toString());
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 2:
        resp = (EditText) contenedor.findViewById(R.id.mtxtEdit);
        result.setItem(1);
        result.setRespuesta(resp.getText().toString());
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 3:
        selectio = (TextView) contenedor.findViewById(R.id.respuestaGruop);
        result.setItem(1);
        result.setRespuesta(selectio.getText().toString());
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 4:

        String resp_opcio = "";
        for (int j = 0; j < contenedor.getChildCount(); j++) {
            View child = contenedor.getChildAt(j);
            if (child instanceof CheckBox) {
                CheckBox hijo = (CheckBox) child;
                if (hijo.isChecked()) {
                    if (resp_opcio.length() == 0) {
                        if (Pregunta.isOpcionEditble(hijo.getText().toString())) {
                            EditText otrosR = (EditText) contenedor.findViewById(R.id.edtTexto);
                            resp_opcio = otrosR.getText().toString();
                        } else {
                            resp_opcio = hijo.getText().toString();
                        }
                    } else {
                        if (Pregunta.isOpcionEditble(hijo.getText().toString())) {
                            EditText otrosR = (EditText) contenedor.findViewById(R.id.edtTexto);
                            resp_opcio += " , " + otrosR.getText().toString() + " ";
                        } else {
                            resp_opcio = resp_opcio + " , " + hijo.getText() + " ";
                        }

                    }
                }
            }

        }
        result.setItem(1);
        result.setRespuesta(resp_opcio);
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 5:
        selectio = (TextView) contenedor.findViewById(R.id.seleEscala);
        result.setItem(1);
        result.setRespuesta(selectio.getText().toString());
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 6:
        Spinner lista = (Spinner) contenedor.findViewById(R.id.opcionesListado);
        result.setItem(1);
        result.setRespuesta(lista.getSelectedItem().toString() + "");
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 7:
        TableLayout tabla = (TableLayout) contenedor.findViewById(R.id.tablaOpciones);
        for (int i = 0; i < tabla.getChildCount(); i++) {
            TableRow registro = (TableRow) tabla.getChildAt(i);
            TextView etiq = (TextView) registro.findViewById(R.id.textoRow);
            RadioGroup selector = (RadioGroup) registro.findViewById(R.id.valoresRow);
            PreguntaRespuesta itemA = new PreguntaRespuesta();
            itemA.setIdPregunta(Pregunta.getIdPregunta());
            itemA.setItem(i + 1);
            itemA.setRespuesta(etiq.getText().toString());
            if (selector.getCheckedRadioButtonId() > 0) {
                RadioButton rb = (RadioButton) selector.findViewById(selector.getCheckedRadioButtonId());
                itemA.setOpcion(rb.getText() + "");
            }

            respuestaList.add(itemA);
            numRespuesta++;
        }

        break;
    case 8:
        DatePicker dp = (DatePicker) contenedor.findViewById(R.id.Fecha_resutl);
        result.setItem(1);
        result.setRespuesta(dp.getYear() + "-" + dp.getMonth() + "-" + dp.getDayOfMonth());
        respuestaList.add(result);
        numRespuesta = 1;
        break;
    case 9:
        TimePicker tp = (TimePicker) contenedor.findViewById(R.id.hora_result);
        result.setItem(1);
        result.setRespuesta(tp.getCurrentHour() + ":" + tp.getCurrentMinute());
        respuestaList.add(result);
        numRespuesta = 1;
        break;

    default:
        result.setItem(1);
        result.setRespuesta("Proceso");
        break;

    }

    return numRespuesta;

}

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 w w. j  a va  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();
        }
    });
}