Example usage for android.widget TableLayout addView

List of usage examples for android.widget TableLayout addView

Introduction

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

Prototype

@Override
public void addView(View child) 

Source Link

Usage

From source file:com.QuarkLabs.BTCeClient.fragments.HomeFragment.java

/**
 * Refreshes funds table with fetched data
 *
 * @param response JSONObject with funds data
 *///  w  w  w .j a  va  2  s  .c o  m
private void refreshFunds(JSONObject response) {
    try {
        if (response == null) {
            Toast.makeText(getActivity(), getResources().getString(R.string.GeneralErrorText),
                    Toast.LENGTH_LONG).show();
            return;
        }
        String notificationText;
        if (response.getInt("success") == 1) {

            View.OnClickListener fillAmount = new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    ScrollView scrollView = (ScrollView) getView();
                    if (scrollView != null) {
                        EditText tradeAmount = (EditText) scrollView.findViewById(R.id.TradeAmount);
                        tradeAmount.setText(((TextView) v).getText());
                        scrollView.smoothScrollTo(0, scrollView.findViewById(R.id.tradingSection).getBottom());
                    }
                }
            };

            notificationText = getResources().getString(R.string.FundsInfoUpdatedtext);
            TableLayout fundsContainer = (TableLayout) getView().findViewById(R.id.FundsContainer);
            fundsContainer.removeAllViews();
            JSONObject funds = response.getJSONObject("return").getJSONObject("funds");
            JSONArray fundsNames = response.getJSONObject("return").getJSONObject("funds").names();
            List<String> arrayList = new ArrayList<>();

            for (int i = 0; i < fundsNames.length(); i++) {
                arrayList.add(fundsNames.getString(i));
            }
            Collections.sort(arrayList);
            TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(0,
                    ViewGroup.LayoutParams.MATCH_PARENT, 1);

            for (String anArrayList : arrayList) {

                TableRow row = new TableRow(getActivity());
                TextView currency = new TextView(getActivity());
                TextView amount = new TextView(getActivity());
                currency.setText(anArrayList.toUpperCase(Locale.US));
                amount.setText(funds.getString(anArrayList));
                currency.setLayoutParams(layoutParams);
                currency.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
                currency.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
                currency.setGravity(Gravity.CENTER);
                amount.setLayoutParams(layoutParams);
                amount.setGravity(Gravity.CENTER);
                amount.setOnClickListener(fillAmount);
                row.addView(currency);
                row.addView(amount);
                fundsContainer.addView(row);
            }

        } else {
            notificationText = response.getString("error");
        }

        mCallback.makeNotification(ConstantHolder.ACCOUNT_INFO_NOTIF_ID, notificationText);

    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:org.mifos.androidclient.main.CustomerChargesDetailsActivity.java

private void updateContent(CustomerChargesDetails details) {
    mDetails = details;//from w w w  .j a va  2 s.co  m
    TextView textView;
    TableLayout table;
    TableRow row;
    View disabledView;
    TableLayoutHelper helper = new TableLayoutHelper(this);

    textView = (TextView) findViewById(R.id.customerChargesDetails_amountDue);
    textView.setText(details.getNextDueAmount().toString());
    textView = (TextView) findViewById(R.id.customerChargesDetails_amountOverdue);
    textView.setText(details.getTotalAmountInArrears().toString());
    textView = (TextView) findViewById(R.id.customerChargesDetails_total);
    textView.setText(details.getTotalAmountDue().toString());

    if (details.getUpcomingInstallment() != null
            && (ValueUtils.hasValue(details.getUpcomingInstallment().getMiscFee())
                    || ValueUtils.hasValue(details.getUpcomingInstallment().getMiscPenalty())
                    || ValueUtils.hasElements(details.getUpcomingInstallment().getFeesActionDetails()))) {

        disabledView = findViewById(R.id.customerChargesDetails_upcomingCharges_label);
        disabledView.setVisibility(View.VISIBLE);
        disabledView = findViewById(R.id.customerChargesDetails_upcomingCharges_scrollView);
        disabledView.setVisibility(View.VISIBLE);

        table = (TableLayout) findViewById(R.id.customerChargesDetails_upcomingCharges_table);

        if (ValueUtils.hasValue(details.getUpcomingInstallment().getMiscFee())) {
            row = helper.createTableRow();
            textView = helper.createTableCell(getString(R.string.customerChargesDetails_miscFee_label), 1);
            row.addView(textView);
            textView = helper.createTableCell(details.getUpcomingInstallment().getMiscFee().toString(), 2);
            row.addView(textView);
            table.addView(row);
            table.addView(helper.createRowSeparator());
        }

        if (ValueUtils.hasValue(details.getUpcomingInstallment().getMiscPenalty())) {
            row = helper.createTableRow();
            textView = helper.createTableCell(getString(R.string.customerChargesDetails_miscPenalty_label), 1);
            row.addView(textView);
            textView = helper.createTableCell(details.getUpcomingInstallment().getMiscPenalty().toString(), 2);
            row.addView(textView);
            table.addView(row);
            table.addView(helper.createRowSeparator());
        }

        if (ValueUtils.hasElements(details.getUpcomingInstallment().getFeesActionDetails())) {
            for (AccountFeeSchedule fee : details.getUpcomingInstallment().getFeesActionDetails()) {
                row = helper.createTableRow();
                textView = helper.createTableCell(fee.getFeeName(), 1);
                row.addView(textView);
                textView = helper.createTableCell(fee.getFeeAmount().toString(), 2);
                row.addView(textView);
                table.addView(row);
                table.addView(helper.createRowSeparator());
            }
        }
    }

    if (ValueUtils.hasElements(details.getRecentActivities())) {
        disabledView = findViewById(R.id.customerChargesDetails_recentAccountActivity_label);
        disabledView.setVisibility(View.VISIBLE);
        disabledView = findViewById(R.id.customerChargesDetails_recentAccountActivity_scrollView);
        disabledView.setVisibility(View.VISIBLE);

        table = (TableLayout) findViewById(R.id.customerChargesDetails_recentAccountActivity_table);

        for (CustomerRecentActivity activity : details.getRecentActivities()) {
            row = helper.createTableRow();
            textView = helper.createTableCell(DateUtils.format(activity.getActivityDate()), 1);
            row.addView(textView);
            textView = helper.createTableCell(activity.getDescription(), 2);
            row.addView(textView);
            textView = helper.createTableCell(activity.getAmount(), 3);
            row.addView(textView);
            textView = helper.createTableCell(activity.getPostedBy(), 4);
            row.addView(textView);
            table.addView(row);
            table.addView(helper.createRowSeparator());
        }
    }

    if (ValueUtils.hasElements(details.getAccountFees())) {
        boolean hasRecurring = false;
        List<AccountFee> recurringFees = new ArrayList<AccountFee>();
        for (AccountFee fee : details.getAccountFees()) {
            if (fee.getMeetingRecurrence() != null) {
                hasRecurring = true;
                recurringFees.add(fee);
            }
        }
        if (hasRecurring) {
            disabledView = findViewById(R.id.customerChargesDetails_recurringAccountFees_label);
            disabledView.setVisibility(View.VISIBLE);
            disabledView = findViewById(R.id.customerChargesDetails_recurringAccountFees_scrollView);
            disabledView.setVisibility(View.VISIBLE);

            table = (TableLayout) findViewById(R.id.customerChargesDetails_recurringAccountFees_table);

            for (AccountFee fee : recurringFees) {
                row = helper.createTableRow();
                textView = helper.createTableCell(fee.getFeeName(), 1);
                row.addView(textView);
                textView = helper.createTableCell(fee.getAccountFeeAmount().toString(), 2);
                row.addView(textView);
                textView = helper.createTableCell(fee.getMeetingRecurrence(), 2);
                row.addView(textView);
                table.addView(row);
                table.addView(helper.createRowSeparator());
            }
        }
    }

}

From source file:com.bonsai.btcreceive.TransactionsFragment.java

private void addTransactionRow(String hash, TableLayout table, String datestr, String timestr, String confstr,
        String btcstr, String btcbalstr, String fiatstr, String fiatbalstr, boolean tintrow) {
    TableRow row = (TableRow) LayoutInflater.from(getActivity()).inflate(R.layout.transaction_table_row, table,
            false);//  w w  w. j  a  va 2  s  .  com

    row.setTag(hash);

    row.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            // Dispatch to the transaction viewer.
            String hash = (String) view.getTag();
            Intent intent = new Intent(getActivity(), ViewTransactionActivity.class);
            intent.putExtra("hash", hash);
            startActivity(intent);
        }
    });

    {
        TextView tv = (TextView) row.findViewById(R.id.row_date);
        tv.setText(datestr);
    }
    {
        TextView tv = (TextView) row.findViewById(R.id.row_time);
        tv.setText(timestr);
    }

    {
        TextView tv = (TextView) row.findViewById(R.id.row_confidence);
        tv.setText(confstr);
    }

    {
        TextView tv = (TextView) row.findViewById(R.id.row_btc_balance);
        tv.setText(btcbalstr);
    }
    {
        TextView tv = (TextView) row.findViewById(R.id.row_btc);
        tv.setText(btcstr);
    }

    {
        TextView tv = (TextView) row.findViewById(R.id.row_fiat_balance);
        tv.setText(fiatbalstr);
    }
    {
        TextView tv = (TextView) row.findViewById(R.id.row_fiat);
        tv.setText(fiatstr);
    }

    if (tintrow)
        row.setBackgroundColor(Color.parseColor("#ccffcc"));

    table.addView(row);
}

From source file:eu.power_switch.gui.adapter.SceneRecyclerViewAdapter.java

@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    final Scene scene = scenes.get(holder.getAdapterPosition());

    String inflaterString = Context.LAYOUT_INFLATER_SERVICE;
    LayoutInflater inflater = (LayoutInflater) fragmentActivity.getSystemService(inflaterString);

    holder.sceneName.setText(scene.getName());
    holder.sceneName.setOnClickListener(new View.OnClickListener() {
        @Override//from   w ww . j  a v a  2  s. c o  m
        public void onClick(View v) {
            if (holder.linearLayoutSceneItems.getVisibility() == View.VISIBLE) {
                holder.linearLayoutSceneItems.setVisibility(View.GONE);
            } else {
                holder.linearLayoutSceneItems.setVisibility(View.VISIBLE);
            }
        }
    });
    holder.sceneName.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            if (onItemLongClickListener != null) {
                onItemLongClickListener.onItemLongClick(v, holder.getAdapterPosition());
            }
            return true;
        }
    });

    holder.buttonActivateScene.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (SmartphonePreferencesHandler.getVibrateOnButtonPress()) {
                VibrationHandler.vibrate(fragmentActivity, SmartphonePreferencesHandler.getVibrationDuration());
            }

            new AsyncTask<Void, Void, Void>() {
                @Override
                protected Void doInBackground(Void... params) {
                    ActionHandler.execute(fragmentActivity, scene);
                    return null;
                }
            }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        }
    });

    // clear previous items
    holder.linearLayoutSceneItems.removeAllViews();
    // hide setup by default
    holder.linearLayoutSceneItems.setVisibility(View.GONE);
    // add current setup
    for (final SceneItem sceneItem : scene.getSceneItems()) {
        // create a new receiverRow for our current receiver and add it
        // to our table of all devices of our current room
        // the row will contain the device name and all buttons
        LinearLayout receiverRow = new LinearLayout(fragmentActivity);
        receiverRow.setOrientation(LinearLayout.HORIZONTAL);
        holder.linearLayoutSceneItems.addView(receiverRow);

        // setup TextView to display receiver name
        AppCompatTextView receiverName = new AppCompatTextView(fragmentActivity);
        receiverName.setText(sceneItem.getReceiver().getName());
        receiverName.setTextSize(18);
        receiverName
                .setTextColor(ThemeHelper.getThemeAttrColor(fragmentActivity, android.R.attr.textColorPrimary));
        receiverName.setGravity(Gravity.CENTER_VERTICAL);
        receiverRow.addView(receiverName,
                new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1.0f));

        TableLayout buttonLayout = new TableLayout(fragmentActivity);
        receiverRow.addView(buttonLayout,
                new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

        int buttonsPerRow;
        if (sceneItem.getReceiver().getButtons().size() % 3 == 0) {
            buttonsPerRow = 3;
        } else {
            buttonsPerRow = 2;
        }

        int i = 0;
        TableRow buttonRow = null;
        for (final Button button : sceneItem.getReceiver().getButtons()) {
            final android.widget.Button buttonView = (android.widget.Button) inflater
                    .inflate(R.layout.simple_button, buttonRow, false);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                buttonView.setElevation(0);
                buttonView.setStateListAnimator(null);
            }
            buttonView.setText(button.getName());
            buttonView.setEnabled(false);

            final int accentColor = ThemeHelper.getThemeAttrColor(fragmentActivity, R.attr.colorAccent);
            final int inactiveColor = ThemeHelper.getThemeAttrColor(fragmentActivity, R.attr.textColorInactive);
            if (sceneItem.getActiveButton().equals(button)) {
                buttonView.setTextColor(accentColor);
            } else {
                buttonView.setTextColor(inactiveColor);
            }

            if (i == 0 || i % buttonsPerRow == 0) {
                buttonRow = new TableRow(fragmentActivity);
                buttonRow.setLayoutParams(
                        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
                buttonRow.addView(buttonView);
                buttonLayout.addView(buttonRow);
            } else {
                buttonRow.addView(buttonView);
            }

            i++;
        }
    }

    if (holder.getAdapterPosition() == getItemCount() - 1) {
        holder.footer.setVisibility(View.VISIBLE);
    } else {
        holder.footer.setVisibility(View.GONE);
    }
}

From source file:com.hybris.mobile.app.commerce.fragment.ProductDetailFragmentBase.java

/**
 * Create table to show data in a table//from w w  w .ja v a  2  s  .co  m
 *
 * @param volumePricingTable : Table which contains from volume pricing for the current product
 */
protected void createVolumePricingTable(TableLayout volumePricingTable) {
    if (mProduct.getVolumePrices() != null) {
        TableRow headerRow = new TableRow(getActivity());

        TextView header1 = new TextView(getActivity());
        header1.setText(getString(R.string.product_detail_volume_qty));
        header1.setTypeface(null, Typeface.BOLD);
        headerRow.addView(header1);

        TextView header2 = new TextView(getActivity());
        header2.setText(getString(R.string.product_detail_volume_price));
        header2.setTypeface(null, Typeface.BOLD);
        headerRow.addView(header2);

        if (mProduct.getVolumePrices().size() > 5) {
            TextView header3 = new TextView(getActivity());
            header3.setText(getString(R.string.product_detail_volume_qty));
            header3.setTypeface(null, Typeface.BOLD);
            headerRow.addView(header3);

            TextView header4 = new TextView(getActivity());
            header4.setText(getString(R.string.product_detail_volume_price));
            header4.setTypeface(null, Typeface.BOLD);
            headerRow.addView(header4);
        }
        volumePricingTable.addView(headerRow);

        for (Price volumePrice : mProduct.getVolumePrices()) {
            TableRow contentRow = new TableRow(getActivity());

            if (volumePrice != null) {
                TextView content1 = new TextView(getActivity());
                content1.setText(volumePrice.getMinQuantity() + " - " + volumePrice.getMaxQuantity());
                contentRow.addView(content1);

                TextView content2 = new TextView(getActivity());
                content2.setText(volumePrice.getFormattedValue());
                contentRow.addView(content2);

                if (mProduct.getVolumePrices().size() > 5) {
                    TextView content3 = new TextView(getActivity());
                    content3.setText(volumePrice.getMinQuantity() + " - " + volumePrice.getMaxQuantity());
                    contentRow.addView(content3);

                    TextView content4 = new TextView(getActivity());
                    content4.setText(volumePrice.getFormattedValue());
                    contentRow.addView(content4);
                }
            } else {
                Log.d(TAG, "Price or Stock is null");
            }

            volumePricingTable.addView(contentRow);
        }
    }

}

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;//w ww. j a v a  2 s.  com

    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:com.cssweb.android.quote.QuoteDetail.java

/**
 * /*from w  w  w  .  j a v  a2  s  .  c o m*/
 * @param jArr
 * @param table
 * @param zrsp
 * @throws JSONException
 */
private void appendRow(JSONArray jArr, TableLayout table, double zrsp) throws JSONException {
    table.setStretchAllColumns(true);
    table.removeAllViews();

    if ("cf".equals(exchange.toLowerCase()) || "dc".equals(exchange.toLowerCase())
            || "sf".equals(exchange.toLowerCase()) || "cz".equals(exchange.toLowerCase())) {
        int len = jArr.length();
        int color = Utils.getTextColor(mContext, 0);
        for (int i = 0; i < len; i++) {
            LinearLayout linearLayout = (LinearLayout) findViewById(R.id.title23);
            linearLayout.setVisibility(View.VISIBLE);

            JSONArray jA = (JSONArray) jArr.get(i);
            TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.zr_quote_price_item, null);
            TextView t1 = (TextView) row.findViewById(R.id.zr_table_col1);
            TextView t2 = (TextView) row.findViewById(R.id.zr_table_col2);
            TextView t3 = (TextView) row.findViewById(R.id.zr_table_col3);
            TextView t4 = (TextView) row.findViewById(R.id.zr_table_col4);
            TextView t5 = (TextView) row.findViewById(R.id.zr_table_col5);
            t1.setText(jA.getString(4));
            t2.setText(Utils.dataFormation(jA.getDouble(0), Utils.getStockDigit(type)));
            t2.setTextColor(Utils.getTextColor(mContext, jA.getDouble(0), zrsp));
            t2.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            double cjsl = Arith.round(jA.getDouble(1), 0);
            t3.setText(Utils.dataFormation(cjsl, 0));
            t3.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            t4.setText(jA.getString(7));
            t5.setText(jA.getString(8));
            table.addView(row);
            if ("B".equals(jA.getString(6))) {
                color = Utils.getTextColor(mContext, 3);
                t3.setTextColor(color);
                t4.setTextColor(color);
                t5.setTextColor(color);
            } else if ("S".equals(jA.getString(6))) {
                color = Utils.getTextColor(mContext, 4);
                t3.setTextColor(color);
                t4.setTextColor(color);
                t5.setTextColor(color);
            } else {
                t3.setTextColor(color);
                t4.setTextColor(color);
                t5.setTextColor(color);
            }
        }
    } else {
        if (stocktype.charAt(0) == '0') {//
            //for (int i = jArr.length()-1; i >= 0; i--) {
            for (int i = 0; i <= jArr.length() - 1; i++) {
                JSONArray jA = (JSONArray) jArr.get(i);
                TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.zr_quote_price_item, null);
                TextView t1 = (TextView) row.findViewById(R.id.zr_table_col1);
                TextView t2 = (TextView) row.findViewById(R.id.zr_table_col2);
                TextView t3 = (TextView) row.findViewById(R.id.zr_table_col3);
                TextView t4 = (TextView) row.findViewById(R.id.zr_table_col4);
                t1.setText(jA.getString(4));
                t2.setText(Utils.dataFormation(jA.getDouble(0), Utils.getStockDigit(type)));
                t2.setTextColor(Utils.getTextColor(mContext, jA.getDouble(0), zrsp));
                t2.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
                double cjsl = Arith.round(jA.getDouble(1), 0);
                t3.setText(Utils.dataFormation(cjsl, 0));
                if (cjsl > 500)
                    t3.setTextColor(Utils.getTextColor(mContext, 6));
                else
                    t3.setTextColor(Utils.getTextColor(mContext, 1));
                t3.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
                t4.setText(jA.getString(6));
                if ("B".equals(jA.getString(6)))
                    t4.setTextColor(Utils.getTextColor(mContext, 3));
                else
                    t4.setTextColor(Utils.getTextColor(mContext, 4));
                table.addView(row);
            }
            //?
            int num = jArr.length();
            if (num < 16) {
                while (num < 16) {
                    TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.zr_quote_price_item,
                            null);
                    table.addView(row);
                    num++;
                }
            }
        } else if (stocktype.charAt(0) == '1' || stocktype.charAt(0) == '2') {//
            //for (int i = jArr.length()-1; i >= 0; i--) {
            for (int i = 0; i <= jArr.length() - 1; i++) {
                JSONArray jA = (JSONArray) jArr.get(i);
                TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.zr_quote_price_item, null);
                TextView t1 = (TextView) row.findViewById(R.id.zr_table_col1);
                TextView t2 = (TextView) row.findViewById(R.id.zr_table_col2);
                TextView t3 = (TextView) row.findViewById(R.id.zr_table_col4);
                t1.setText(jA.getString(4));
                t2.setText(Utils.dataFormation(jA.getDouble(0), Utils.getStockDigit(type)));
                t2.setTextColor(Utils.getTextColor(mContext, jA.getDouble(0), zrsp));
                t3.setText(Utils.getAmountFormat(jA.getDouble(5), true));
                t3.setTextColor(Utils.getTextColor(mContext, 1));
                table.addView(row);
            }
            //?
            int num = jArr.length();
            if (num < 16) {
                while (num < 16) {
                    TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.zr_quote_price_item,
                            null);
                    table.addView(row);
                    num++;
                }
            }
        }
    }

}

From source file:com.money.manager.ex.home.DashboardFragment.java

private View showTableLayoutUpComingTransactions(Cursor cursor) {
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.dashboard_summary_layout, null);
    CurrencyService currencyService = new CurrencyService(getActivity().getApplicationContext());
    Core core = new Core(getActivity().getApplicationContext());

    // Textview Title
    TextView title = (TextView) layout.findViewById(R.id.textViewTitle);
    title.setText(R.string.upcoming_transactions);
    // Table/*from w w  w.j  av a  2 s. co  m*/
    TableLayout tableLayout = (TableLayout) layout.findViewById(R.id.tableLayoutSummary);
    // add rows
    while (cursor.moveToNext()) {
        // load values
        String payee = "<i>" + cursor.getString(cursor.getColumnIndex(QueryBillDeposits.PAYEENAME)) + "</i>";
        double total = cursor.getDouble(cursor.getColumnIndex(QueryBillDeposits.AMOUNT));
        int daysLeft = cursor.getInt(cursor.getColumnIndex(QueryBillDeposits.DAYSLEFT));
        int currencyId = cursor.getInt(cursor.getColumnIndex(QueryBillDeposits.CURRENCYID));
        String daysLeftText = "";
        daysLeftText = Integer.toString(Math.abs(daysLeft)) + " "
                + getString(daysLeft >= 0 ? R.string.days_remaining : R.string.days_overdue);
        TableRow row = createTableRow(
                new String[] { "<small>" + payee + "</small>",
                        "<small>" + currencyService.getCurrencyFormatted(currencyId,
                                MoneyFactory.fromDouble(total)) + "</small>",
                        "<small>" + daysLeftText + "</small>" },
                new Float[] { 1f, null, 1f }, new Integer[] { null, Gravity.RIGHT, Gravity.RIGHT },
                new Integer[][] { null, { 0, 0, padding_in_px, 0 }, null });
        TextView txt = (TextView) row.getChildAt(2);
        UIHelper uiHelper = new UIHelper(getActivity());
        int color = daysLeft >= 0 ? uiHelper.resolveAttribute(R.attr.holo_green_color_theme)
                : uiHelper.resolveAttribute(R.attr.holo_red_color_theme);
        txt.setTextColor(ContextCompat.getColor(getActivity(), color));
        // Add Row
        tableLayout.addView(row);
    }
    // return Layout
    return layout;
}

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

private void populateUpcomingDates() {
    long startTime = System.currentTimeMillis();
    TableLayout dateListTable = (TableLayout) getView().findViewById(R.id.dates);
    dateListTable.removeAllViews();/*from   ww w  .  j  a  va2  s  .c o  m*/

    if (mDashboardModel.getDates().isEmpty()) {
        getView().findViewById(R.id.dates_empty).setVisibility(View.VISIBLE);
        return;
    } else {
        getView().findViewById(R.id.dates_empty).setVisibility(View.GONE);
    }

    Termin previousDate = null;
    for (Termin date : mDashboardModel.getDates()) {
        Date from = date.getDatum();

        View dateTableRow = getActivity().getLayoutInflater().inflate(R.layout.dashboard_date, dateListTable,
                false);
        TextView dateText = (TextView) dateTableRow.findViewById(R.id.text_date);
        TextView timeText = (TextView) dateTableRow.findViewById(R.id.text_time);
        TextView roomText = (TextView) dateTableRow.findViewById(R.id.text_room);
        TextView titleText = (TextView) dateTableRow.findViewById(R.id.text_title);

        dateText.setText(getString(R.string.calendar_date, from));
        timeText.setText(getString(R.string.calendar_time, from));
        roomText.setText(date.getRaum());
        titleText.setText(date.getTitleWithType());

        int color = 0;
        if (date.isStorniert()) {
            color = getResources().getColor(R.color.date_canceled);
        } else if (date.isNow()) {
            color = getResources().getColor(R.color.date_running);
        }
        if (color != 0) {
            dateText.setTextColor(color);
            timeText.setTextColor(color);
            roomText.setTextColor(color);
            titleText.setTextColor(color);
        }

        if (previousDate != null && Utils.isSameDay(previousDate.getDatum(), date.getDatum())) {
            dateText.setVisibility(View.INVISIBLE);
        }

        dateTableRow.setVisibility(View.INVISIBLE); // will be unhidden by #adjustDateListHeight()
        dateListTable.addView(dateTableRow);
        previousDate = date;
    }
    long deltaTime = System.currentTimeMillis() - startTime;
    Log.d(TAG, "populateUpcomingDates: " + deltaTime + "ms");
    adjustDateListHeight();
}

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  2 s  .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);
    }
}