Example usage for android.widget TableRow getChildAt

List of usage examples for android.widget TableRow getChildAt

Introduction

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

Prototype

public View getChildAt(int index) 

Source Link

Document

Returns the view at the specified position in the group.

Usage

From source file:ru.adios.budgeter.widgets.DataTableLayout.java

public void disableUserOrdering() {
    orderResolver = Optional.empty();
    if (getChildCount() > 0) {
        final TableRow columnsRow = (TableRow) getChildAt(2);
        for (int i = 0; i < columnsRow.getChildCount(); i++) {
            final View childAt = columnsRow.getChildAt(i);
            if (childAt.isSelected()) {
                childAt.setSelected(false);
                childAt.invalidate();/*  w  w  w . j a va 2  s  .co  m*/
                break;
            }
        }
    }
}

From source file:ru.adios.budgeter.widgets.DataTableLayout.java

private void setOrderByInternal(OrderBy orderBy, boolean doReloadIfNeeded) {
    checkState(!orderResolver.isPresent() || orderBy != null,
            "User ordering enabled, cannot set no ordering at all");

    if ((this.orderBy.isPresent() && !this.orderBy.get().equals(orderBy))
            || (!this.orderBy.isPresent() && orderBy != null)) {
        if (orderResolver.isPresent() && columnsRow.isPresent()) {
            final TableRow[] colsRow = columnsRow.get();

            outer: for (final TableRow r : colsRow) {
                for (int j = 0; j < r.getChildCount(); j++) {
                    final TextView col = (TextView) r.getChildAt(j);

                    if (col.getText().toString()
                            .equals(orderResolver.get().byField(orderBy.field).orElse(null))) {
                        if (!col.isSelected()) {
                            selectOrderByColumn(col);
                        }// ww w  . j a  v a2 s.  c om
                        break outer;
                    }
                }
            }
        }

        this.orderBy = Optional.ofNullable(orderBy);

        if (tablePopulated && doReloadIfNeeded) {
            clearContents();
            loadTableProcedures();
        }
    }
}

From source file:ru.adios.budgeter.widgets.DataTableLayout.java

public void enableUserOrdering(OrderResolver orderResolver) {
    checkArgument(orderResolver != null, "orderResolver is null");
    this.orderResolver = Optional.of(orderResolver);
    if (getChildCount() > 0) {
        final TableRow columnsRow = (TableRow) getChildAt(2);
        for (int i = 0; i < columnsRow.getChildCount(); i++) {
            final TextView col = (TextView) columnsRow.getChildAt(i);
            final String text = col.getText().toString();

            if (!orderBy.isPresent()) {
                final Optional<OrderBy> possibleOrder = orderResolver.byColumnName(text, Order.DESC);
                if (!possibleOrder.isPresent()) {
                    continue;
                }/*ww w. ja  va 2s  .co  m*/
                orderBy = Optional.of(possibleOrder.get());
                selectOrderByColumn(col);
                if (tablePopulated) {
                    clearContents();
                    loadTableProcedures();
                }
                return;
            }

            if (text.equals(orderResolver.byField(orderBy.get().field).orElse(null))) {
                if (!col.isSelected()) {
                    selectOrderByColumn(col);
                    col.invalidate();
                }
                break;
            }
        }
    }
}

From source file:com.nearnotes.NoteEdit.java

@Override
public void onStart() {
    super.onStart();
    mTitleText = (EditText) getActivity().findViewById(R.id.title_edit);

    mCallback.setActionItems(NOTE_EDIT);
    if (mRowId == null) {
        Bundle extras = getArguments();//from  w w w .j a  va 2s. co  m
        mRowId = extras.containsKey(NotesDbAdapter.KEY_ROWID) ? extras.getLong(NotesDbAdapter.KEY_ROWID) : null;
    }

    getActivity().setTitle(R.string.edit_note);

    Bundle bundle = getArguments();
    mLongitude = bundle.getDouble("longitude");
    mLatitude = bundle.getDouble("latitude");

    mTitleText = (EditText) getActivity().findViewById(R.id.title_edit);
    mBodyText = (EditText) getView().findViewById(R.id.body);

    mTblAddLayout = (TableLayout) getActivity().findViewById(R.id.checkbody);
    mTblAddLayout.setPadding(0, 0, 0, 0);

    acAdapter = new PlacesAutoCompleteAdapter(getActivity(), R.layout.list_item);

    mCheckBox = (CheckBox) getActivity().findViewById(R.id.checkbox_on_top);
    mCheckBox.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (((CheckBox) v).isChecked() && mRowId != null) {
                mDbHelper.updateSetting(mRowId);
            } else if (mRowId != null) {
                mDbHelper.removeSetting();
            }
        }
    });

    autoCompView = (DelayAutoCompleteTextView) getView().findViewById(R.id.autoCompleteTextView1);
    autoCompView.setAdapter(acAdapter);
    //int height = autoCompView.getDropDownHeight();
    //autoCompView.setDropDownHeight(height + 20);

    autoCompView.setOnItemClickListener(this);
    autoCompView.setLoadingIndicator((ProgressBar) getView().findViewById(R.id.progressAPI),
            (ImageView) getView().findViewById(R.id.location_icon));

    autoCompView.setCompletionHint("");
    if (mRowId != null) {
        autoCompView.setTextColor(getResources().getColor(R.color.deepgreen));
    } else {
        SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());
        boolean checklistPref = sharedPref.getBoolean("pref_key_note_checklist", false);
        if (checklistPref) {
            mChecklist = true;
        }
    }

    mBodyText.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
        @SuppressWarnings("deprecation")
        @Override
        public void onGlobalLayout() {
            //This listener is added to make sure the globalLayout has been displayed
            // before accessing getLayout().getLineEnd()
            ViewTreeObserver obs = mBodyText.getViewTreeObserver();
            obs.removeGlobalOnLayoutListener(this);

            if (!mChecklist) {
                return;
            }
            mBodyText.addTextChangedListener(bodyTextWatcher);

            // Run the code below just once on startup to populate the global listArray mRealRow
            String tempBoxes = mBodyText.getText().toString();
            if (mBodyText.getLayout() != null) {
                mRealRow = populateBoxes(tempBoxes);

                int row = 0;
                for (NoteRow line : mRealRow) {
                    switch (line.getType()) {
                    case 0:
                        TableRow inflate = (TableRow) View.inflate(getActivity(), R.layout.table_row_invisible,
                                null);
                        mTblAddLayout.addView(inflate);
                        break;
                    case 1:
                        TableRow checkRow = (TableRow) View.inflate(getActivity(), R.layout.table_row, null);
                        CheckBox temp = (CheckBox) checkRow.getChildAt(0);
                        temp.setTag(Integer.valueOf(row));
                        mTblAddLayout.addView(checkRow);
                        temp.setOnClickListener(checkBoxListener);
                        break;
                    case 2:
                        TableRow checkRow1 = (TableRow) View.inflate(getActivity(), R.layout.table_row, null);
                        CheckBox temp1 = (CheckBox) checkRow1.getChildAt(0);
                        temp1.setTag(Integer.valueOf(row));
                        temp1.setChecked(true);
                        mTblAddLayout.addView(checkRow1);
                        temp1.setOnClickListener(checkBoxListener);
                        break;
                    }

                    for (int k = 1; line.getSize() > k; k++) {
                        TableRow inflate = (TableRow) View.inflate(getActivity(), R.layout.table_row_invisible,
                                null);
                        mTblAddLayout.addView(inflate);
                    }
                    row++;
                }
            }
        }
    });
}

From source file:hongik.android.project.best.StoreActivity.java

public void drawPage() throws Exception {
    String query = "func=storereview" + "&license=" + license;

    DBConnector conn = new DBConnector(query);
    conn.start();//from   w  w w  .j  a v  a2 s. c  o  m
    conn.join();

    JSONObject jsonResult = conn.getResult();
    boolean result = jsonResult.getBoolean("result");
    if (!result)
        return;

    final JSONObject store = jsonResult.getJSONArray("store").getJSONObject(0);

    JSONArray menu = null;
    if (!jsonResult.isNull("menu"))
        menu = jsonResult.getJSONArray("menu");

    JSONArray review = null;
    if (!jsonResult.isNull("review"))
        review = jsonResult.getJSONArray("review");

    //Draw Store Information
    Lat = Double.parseDouble(store.getString("LAT"));
    Lng = Double.parseDouble(store.getString("LNG"));
    sname = store.getString("SNAME");
    ((TextViewPlus) findViewById(R.id.store_storename)).setText(sname);
    ((TextViewPlus) findViewById(R.id.store_address)).setText(store.getString("ADDR"));
    ImageLoader imgLoader = new ImageLoader(store.getString("IMG"));
    imgLoader.start();

    try {
        imgLoader.join();
        Bitmap storeImg = imgLoader.getBitmap();
        ((ImageView) findViewById(R.id.store_image)).setImageBitmap(storeImg);
    } catch (InterruptedException e) {
        Toast.makeText(this, "Can not bring " + license + "store's image", Toast.LENGTH_SHORT).show();
        Log.e("StoreInfo", "Can not bring " + license + "store's image");
    }

    //Draw Menu Table
    if (menu != null) {
        TableRow motive = (TableRow) menuTable.getChildAt(1);

        for (int i = 0; i < menu.length(); i++) {
            JSONObject json = menu.getJSONObject(i);

            TableRow tbRow = new TableRow(this);
            TextViewPlus[] tbCols = new TextViewPlus[3];

            final String[] elements = new String[2];
            elements[0] = json.getString("ITEM#");
            elements[1] = json.getString("PRICE");

            imgLoader = new ImageLoader(json.getString("IMG"));
            imgLoader.start();
            imgLoader.join();

            ImageView img = new ImageView(this);
            Bitmap bitmap = imgLoader.getBitmap();
            img.setImageBitmap(bitmap);
            img.setLayoutParams(motive.getChildAt(0).getLayoutParams());
            img.setScaleType(ImageView.ScaleType.FIT_XY);
            img.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent storeIntent = new Intent(originActivity, MenuActivity.class);
                    storeIntent.putExtra("LICENSE", license);
                    storeIntent.putExtra("MENU", elements[0]);
                    startActivity(storeIntent);
                }
            });

            tbRow.addView(img);

            for (int j = 0; j < 2; j++) {
                tbCols[j] = new TextViewPlus(this);
                tbCols[j].setText(elements[j]);
                tbCols[j].setLayoutParams(motive.getChildAt(j + 1).getLayoutParams());
                tbCols[j].setGravity(Gravity.CENTER);
                tbCols[j].setTypeface(Typeface.createFromAsset(tbCols[j].getContext().getAssets(),
                        "InterparkGothicBold.ttf"));
                tbCols[j].setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent storeIntent = new Intent(originActivity, MenuActivity.class);
                        storeIntent.putExtra("LICENSE", license);
                        storeIntent.putExtra("MENU", elements[0]);
                        startActivity(storeIntent);
                    }
                });

                Log.i("StoreMenu", "COL" + j + ":" + elements[j]);
                tbRow.addView(tbCols[j]);
            }
            menuTable.addView(tbRow);
        }
    }
    menuTable.removeViewAt(1);

    //Draw Review Table
    if (review != null) {
        TableRow motive = (TableRow) reviewTable.getChildAt(1);

        int rowCnt = 5;
        if (review.length() < 5)
            rowCnt = review.length();
        for (int i = 0; i < rowCnt; i++) {
            JSONObject json = review.getJSONObject(i);

            final String[] elements = new String[4];
            elements[0] = Double.parseDouble(json.getString("GRADE")) + "";
            elements[1] = json.getString("NOTE");
            elements[2] = json.getString("CID#");
            elements[3] = json.getString("DAY");

            TableRow tbRow = new TableRow(this);
            TextViewPlus[] tbCols = new TextViewPlus[4];

            if (elements[1].length() > 14)
                elements[1] = elements[1].substring(0, 14) + "...";

            for (int j = 0; j < 4; j++) {
                tbCols[j] = new TextViewPlus(this);
                tbCols[j].setText(elements[j]);
                tbCols[j].setLayoutParams(motive.getChildAt(j).getLayoutParams());
                tbCols[j].setGravity(Gravity.CENTER);
                tbCols[j].setTypeface(Typeface.createFromAsset(tbCols[j].getContext().getAssets(),
                        "InterparkGothicBold.ttf"));
                tbCols[j].setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent reviewIntent = new Intent(originActivity, ReviewDetailActivity.class);
                        reviewIntent.putExtra("ACCESS", "STORE");
                        reviewIntent.putExtra("CID", elements[2]);
                        reviewIntent.putExtra("LICENSE", license);
                        Log.i("StoreReview", "StartActivity");
                        startActivity(reviewIntent);
                    }
                });

                Log.i("StoreMenu", "COL" + j + ":" + elements[j]);
                tbRow.addView(tbCols[j]);
            }
            reviewTable.addView(tbRow);
        }
    }
    reviewTable.removeViewAt(1);

    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.store_map);
    mapFragment.getMapAsync(this);
}

From source file:ru.adios.budgeter.widgets.DataTableLayout.java

private TextView createSpyingColumnForTableRow(String text, final int rowId, final float weight,
        Context context) {/*w  ww  . j  a v  a 2s . c  om*/
    final SpyingTextView view = new SpyingTextView(context);
    populateColumn(view, context, weight);
    view.heightCatch = true;
    view.setHeightRunnable(new Runnable() {
        @Override
        public void run() {
            final TableRow row = (TableRow) getChildAt(rowId);
            final int childCount = row.getChildCount();

            int maxHeight = 0;
            for (int i = 0; i < childCount; i++) {
                final TextView childAt = (TextView) row.getChildAt(i);
                maxHeight = Math.max(maxHeight, childAt.getHeight());
            }

            for (int i = 0; i < childCount; i++) {
                final TextView childAt = (TextView) row.getChildAt(i);
                childAt.setLayoutParams(
                        new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, maxHeight, weight));
            }

            invalidate();
        }
    });
    view.setText(text);
    return view;
}

From source file:com.mifos.mifosxdroid.online.generatecollectionsheet.GenerateCollectionSheetFragment.java

private void submitProductiveSheet() {
    ProductiveCollectionSheetPayload payload = new ProductiveCollectionSheetPayload();

    payload.setCalendarId(calendarId);/* w ww .j  a v  a  2s  .com*/
    payload.setTransactionDate(tvMeetingDate.getText().toString());

    for (int i = 0; i < tableProductive.getChildCount(); i++) {
        //In the tableRows which depicts the details of that client.
        //Loop through all the view of this TableRows.

        TableRow row = (TableRow) tableProductive.getChildAt(i);
        for (int j = 0; j < row.getChildCount(); j++) {
            //In a particular TableRow
            //Loop through the views and check if it's LinearLayout
            //because the required views - EditTexts are there only.

            View v = row.getChildAt(j);
            if (v instanceof LinearLayout) {
                //So, we got into the container containing the EditTexts
                //Now, extract the values and the loanId associated to this
                //particular TextView which was set as its Tag.

                for (int k = 0; k < ((LinearLayout) v).getChildCount(); k++) {
                    EditText et = (EditText) ((LinearLayout) v).getChildAt(k);
                    String[] typeId = et.getTag().toString().split(":");
                    //Switch on basis if whether it's LOAN or SAVING
                    switch (typeId[0]) {
                    case TYPE_LOAN:
                        int loanId = Integer.parseInt(typeId[1]);
                        Double amount = Double.parseDouble(et.getText().toString());
                        payload.getBulkRepaymentTransactions()
                                .add(new BulkRepaymentTransactions(loanId, amount));
                        break;
                    //Saving products are NOT shown in ProductiveSheet.
                    //So, not processing them.
                    }
                }
            }
        }
    }

    //Payload with all the items is ready. Now, hit the endpoint and submit it.
    presenter.submitProductiveSheet(productiveCenterId, payload);
}

From source file:com.mifos.mifosxdroid.online.generatecollectionsheet.GenerateCollectionSheetFragment.java

private void submitCollectionSheet() {
    CollectionSheetPayload payload = new CollectionSheetPayload();

    payload.setCalendarId(calendarId);//from  w w w.ja  v  a2 s  .  c  om
    payload.setTransactionDate(tvMeetingDate.getText().toString());
    payload.setActualDisbursementDate(tvMeetingDate.getText().toString());

    for (int i = 0; i < tableProductive.getChildCount(); i++) {
        //In the tableRows which depicts the details of that client.
        //Loop through all the view of this TableRows.

        TableRow row = (TableRow) tableProductive.getChildAt(i);
        for (int j = 0; j < row.getChildCount(); j++) {
            //In a particular TableRow
            //Loop through the views and check if it's LinearLayout
            //because the required views - EditTexts are there only.

            View v = row.getChildAt(j);
            if (v instanceof LinearLayout) {
                //So, we got into the container containing the EditTexts
                //Now, extract the values and the loanId associated to this
                //particular TextView which was set as its Tag.

                for (int k = 0; k < ((LinearLayout) v).getChildCount(); k++) {
                    EditText et = (EditText) ((LinearLayout) v).getChildAt(k);
                    String[] typeId = et.getTag().toString().split(":");
                    //Switch on basis if whether it's LOAN or SAVING
                    switch (typeId[0]) {
                    case TYPE_LOAN:
                        int loanId = Integer.parseInt(typeId[1]);
                        Double amount = Double.parseDouble(et.getText().toString());
                        payload.getBulkRepaymentTransactions()
                                .add(new BulkRepaymentTransactions(loanId, amount));
                        break;

                    case TYPE_SAVING:
                        //Add to Savings
                        int savingsId = Integer.parseInt(typeId[1]);
                        String amountSaving = et.getText().toString();
                        payload.getBulkSavingsDueTransactions()
                                .add(new BulkSavingsDueTransaction(savingsId, amountSaving));
                        break;
                    }

                }
            } else if (v instanceof Spinner) {
                //Attendance
                Spinner spinner = (Spinner) v;
                int clientId = (int) spinner.getTag();
                int attendanceTypeId = attendanceTypeOptions.get(spinner.getSelectedItem().toString());
                payload.getClientsAttendance().add(new ClientsAttendance(clientId, attendanceTypeId));
            }
        }
    }

    //Check if Additional details are there
    if (tableAdditional != null && tableAdditional.getChildCount() > 0) {
        for (int i = 0; i < 6; i++) {
            TableRow row = (TableRow) tableAdditional.getChildAt(i);
            View v = row.getChildAt(1);

            if (v instanceof Spinner) {
                int paymentId = additionalPaymentTypeMap.get(((Spinner) v).getSelectedItem().toString());
                if (paymentId != -1) {
                    payload.setPaymentTypeId(paymentId);
                }
            } else if (v instanceof EditText) {
                String value = ((EditText) v).getText().toString();
                if (!value.equals("")) {
                    switch (i) {
                    case 1:
                        payload.setAccountNumber(value);
                        break;

                    case 2:
                        payload.setCheckNumber(value);
                        break;

                    case 3:
                        payload.setRoutingCode(value);
                        break;

                    case 4:
                        payload.setReceiptNumber(value);
                        break;

                    case 5:
                        payload.setBankNumber(value);
                        break;
                    }
                }
            }
        }
    }

    //Payload with all the items is ready. Now, hit the endpoint and submit it.
    presenter.submitCollectionSheet(groupId, payload);
}

From source file:hongik.android.project.best.HistoryActivity.java

public void drawHistory() {
    int rowCnt = historyTable.getChildCount();
    Log.i("ROWCOUNT", rowCnt + "");
    String query = "func=history&cid=" + cid;
    DBConnector conn = new DBConnector(query);
    conn.start();/*from  w  w  w .j  a  va 2  s . com*/

    try {
        conn.join();
        JSONObject jsonResult = conn.getResult();
        boolean result = (boolean) jsonResult.get("result");

        if (!result)
            return;

        TableRow motive = (TableRow) historyTable.getChildAt(1);
        JSONArray jsonArray = jsonResult.getJSONArray("values");

        for (int i = 0; i < jsonArray.length(); i++) {
            TableRow tbRow = new TableRow(this);
            final TextViewPlus[] tbCols = new TextViewPlus[4];
            JSONObject json = jsonArray.getJSONObject(i);
            String[] elements = new String[4];

            elements[0] = json.getString("SNAME");
            elements[1] = Double.parseDouble(json.getString("GRADE")) + "";
            elements[2] = json.getString("NOTE");
            elements[3] = json.getString("DAY");
            final String license = json.getString("LICENSE#");

            if (elements[2].length() > 14)
                elements[2] = elements[2].substring(0, 14) + "...";

            for (int j = 0; j < 4; j++) {
                tbCols[j] = new TextViewPlus(this);
                tbCols[j].setText(elements[j]);
                tbCols[j].setLayoutParams(motive.getChildAt(j).getLayoutParams());
                tbCols[j].setGravity(Gravity.CENTER);
                tbCols[j].setTypeface(Typeface.createFromAsset(tbCols[j].getContext().getAssets(),
                        "InterparkGothicBold.ttf"));
                final HistoryActivity originActivity = this;
                tbCols[j].setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent reviewIntent = new Intent(originActivity, ReviewDetailActivity.class);
                        reviewIntent.putExtra("ACCESS", "HISTORY");
                        reviewIntent.putExtra("CID", cid);
                        reviewIntent.putExtra("LICENSE", license);
                        startActivity(reviewIntent);
                    }
                });

                Log.i("History", "COL" + j + ":" + elements[j]);

                tbRow.addView(tbCols[j]);
            }
            historyTable.addView(tbRow);
        }
        for (int i = 1; i < rowCnt; i++) {
            historyTable.removeViewAt(1);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

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));
        }//from  ww  w .  j a va  2  s .  c  o  m
    }
}