Example usage for android.widget TableRow TableRow

List of usage examples for android.widget TableRow TableRow

Introduction

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

Prototype

public TableRow(Context context) 

Source Link

Document

Creates a new TableRow for the given context.

Usage

From source file:com.vonglasow.michael.satstat.RadioSectionFragment.java

protected void showCellGsm(CellTowerGsm cell) {
    TableRow row = new TableRow(rilCells.getContext());
    row.setWeightSum(29);/*from  ww w .  ja  v a2s. c  o m*/

    TextView newType = new TextView(rilCells.getContext());
    newType.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2));
    newType.setTextAppearance(rilCells.getContext(), android.R.style.TextAppearance_Medium);
    newType.setTextColor(
            rilCells.getContext().getResources().getColor(getColorFromGeneration(cell.getGeneration())));
    newType.setText(rilCells.getContext().getResources().getString(R.string.smallDot));
    row.addView(newType);

    TextView newMcc = new TextView(rilCells.getContext());
    newMcc.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
    newMcc.setTextAppearance(rilCells.getContext(), android.R.style.TextAppearance_Medium);
    newMcc.setText(formatCellData(rilCells.getContext(), "%03d", cell.getMcc()));
    row.addView(newMcc);

    TextView newMnc = new TextView(rilCells.getContext());
    newMnc.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
    newMnc.setTextAppearance(rilCells.getContext(), android.R.style.TextAppearance_Medium);
    newMnc.setText(formatCellData(rilCells.getContext(), "%02d", cell.getMnc()));
    row.addView(newMnc);

    TextView newLac = new TextView(rilCells.getContext());
    newLac.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 5));
    newLac.setTextAppearance(rilCells.getContext(), android.R.style.TextAppearance_Medium);
    newLac.setText(formatCellData(rilCells.getContext(), null, cell.getLac()));
    row.addView(newLac);

    TextView newCid = new TextView(rilCells.getContext());
    newCid.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 9));
    newCid.setTextAppearance(rilCells.getContext(), android.R.style.TextAppearance_Medium);
    if ((mainActivity.prefCid) && (cell.getCid() != CellTower.UNKNOWN) && (cell.getCid() > 0x0ffff)) {
        int rtcid = cell.getCid() / 0x10000;
        int cid = cell.getCid() % 0x10000;
        newCid.setText(String.format("%d-%d", rtcid, cid));
    } else
        newCid.setText(formatCellData(rilCells.getContext(), null, cell.getCid()));
    row.addView(newCid);

    TextView newPsc = new TextView(rilCells.getContext());
    newPsc.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
    newPsc.setTextAppearance(rilCells.getContext(), android.R.style.TextAppearance_Medium);
    newPsc.setText(formatCellData(rilCells.getContext(), null, cell.getPsc()));
    row.addView(newPsc);

    TextView newDbm = new TextView(rilCells.getContext());
    newDbm.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 4));
    newDbm.setTextAppearance(rilCells.getContext(), android.R.style.TextAppearance_Medium);
    newDbm.setText(formatCellDbm(rilCells.getContext(), null, cell.getDbm()));
    row.addView(newDbm);

    rilCells.addView(row, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}

From source file:org.brandroid.openmanager.fragments.DialogHandler.java

private static void fillShortcutsTable(TableLayout table) {
    final Context context = table.getContext();
    for (int sc : MenuUtils.getMenuShortcuts(context)) {
        TableRow tr = new TableRow(context);
        TextView tv1 = new TextView(context);
        tv1.setGravity(Gravity.RIGHT);/*  www.j  a  v a  2  s .c om*/
        tv1.setPadding(20, 0, 20, 0);
        char scc = (char) (sc + ('a' - KeyEvent.KEYCODE_A));
        tv1.setText("" + scc);
        TextView tv2 = new TextView(context);
        MenuItem item = MenuUtils.getMenuShortcut(sc);
        tv2.setText(item.getTitle());
        tr.addView(tv1);
        tr.addView(tv2);
        table.addView(tr);
    }
}

From source file:com.example.drugsformarinemammals.Dose_Information.java

public void show_dose(ArrayList<Dose_Data> dose, TableLayout dose_table, TableRow dose_data, String drug_name,
        String group_name, String animal_family, String animal_name, String animal_category,
        ArrayList<String> notes, ArrayList<String> references, ArrayList<Article_Reference> references_index) {

    String doseAmount;/*from  w  ww.  jav  a 2s.c o  m*/
    String dosePosology;
    String doseRoute;
    String doseBookReference;
    String doseArticleReference;
    for (int k = 0; k < dose.size(); k++) {
        if (k > 0) {
            dose_data = new TableRow(this);
        }

        doseAmount = dose.get(k).getAmount();
        dosePosology = dose.get(k).getPosology();
        doseRoute = dose.get(k).getRoute();
        doseBookReference = dose.get(k).getBookReference();
        doseArticleReference = dose.get(k).getArticleReference();

        //Dose amount data

        TextView textView_animal_dose_amount = new TextView(this);
        textView_animal_dose_amount.setText(doseAmount);
        textView_animal_dose_amount.setSingleLine(false);
        textView_animal_dose_amount.setTextColor(Color.BLACK);
        textView_animal_dose_amount.setTextSize(15);
        textView_animal_dose_amount.setTypeface(Typeface.SANS_SERIF);
        TableRow.LayoutParams paramsDoseAmount = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                TableRow.LayoutParams.WRAP_CONTENT);
        paramsDoseAmount.gravity = Gravity.CENTER;
        dose_data.addView(textView_animal_dose_amount, paramsDoseAmount);

        //Dose posology data

        TextView textView_animal_dose_posology = new TextView(this);
        textView_animal_dose_posology.setText(dosePosology);
        textView_animal_dose_posology.setSingleLine(false);
        textView_animal_dose_posology.setTextColor(Color.BLACK);
        textView_animal_dose_posology.setTextSize(15);
        textView_animal_dose_posology.setTypeface(Typeface.SANS_SERIF);
        TableRow.LayoutParams paramsDosePosology = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                TableRow.LayoutParams.WRAP_CONTENT);
        paramsDosePosology.gravity = Gravity.CENTER;
        if ((screenWidth < 600 && !isCollapsed(drug_name, group_name, animal_family, "Posology"))
                || screenWidth >= 600)
            dose_data.addView(textView_animal_dose_posology, paramsDosePosology);

        //Dose route data

        TextView textView_animal_dose_route = new TextView(this);
        textView_animal_dose_route.setText(doseRoute);
        textView_animal_dose_route.setSingleLine(false);
        textView_animal_dose_route.setTextColor(Color.BLACK);
        textView_animal_dose_route.setTextSize(15);
        textView_animal_dose_route.setTypeface(Typeface.SANS_SERIF);
        if (screenWidth >= 600) {
            TableRow.LayoutParams paramsDoseRoute = new TableRow.LayoutParams(
                    TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
            paramsDoseRoute.gravity = Gravity.CENTER;
            dose_data.addView(textView_animal_dose_route, paramsDoseRoute);
        } else {
            TableRow.LayoutParams paramsDoseRoute = new TableRow.LayoutParams(30,
                    TableRow.LayoutParams.WRAP_CONTENT);
            paramsDoseRoute.gravity = Gravity.CENTER;
            dose_data.addView(textView_animal_dose_route, paramsDoseRoute);
        }

        //Dose reference data

        TextView textView_animal_dose_reference = new TextView(this);
        if (!doseBookReference.equals(""))
            textView_animal_dose_reference.setText(doseBookReference);
        else if (!doseArticleReference.equals("")) {
            if (!references.contains(doseArticleReference)) {
                references.add(references.size(), doseArticleReference);
                Article_Reference article_reference = new Article_Reference(reference_index,
                        doseArticleReference);
                references_index.add(references_index.size(), article_reference);
                reference_index++;
            }
            int article_index = references.indexOf(doseArticleReference);
            textView_animal_dose_reference.setText("(" + references_index.get(article_index).getIndex() + ")");
        }
        textView_animal_dose_reference.setSingleLine(false);
        textView_animal_dose_reference.setTextColor(Color.BLACK);
        textView_animal_dose_reference.setTextSize(15);
        textView_animal_dose_reference.setTypeface(Typeface.SANS_SERIF);
        if (screenWidth >= 600) {
            TableRow.LayoutParams paramsDoseReference = new TableRow.LayoutParams(
                    TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
            paramsDoseReference.gravity = Gravity.CENTER;
            dose_data.addView(textView_animal_dose_reference, paramsDoseReference);
        } else {
            TableRow.LayoutParams paramsDoseReference = new TableRow.LayoutParams(150,
                    TableRow.LayoutParams.WRAP_CONTENT);
            paramsDoseReference.gravity = Gravity.CENTER;
            dose_data.addView(textView_animal_dose_reference, paramsDoseReference);
        }

        //Specific note index

        ArrayList<String> specific_notes = new ArrayList<String>();
        specific_notes = helper.read_specific_notes(drug_name, group_name, animal_name, animal_family,
                animal_category, doseAmount, dosePosology, doseRoute, doseBookReference, doseArticleReference);

        String index = "";
        for (int m = 0; m < specific_notes.size(); m++) {
            String note = specific_notes.get(m);
            if (!notes.contains(note)) {
                notes.add(notes.size(), note);
            }
            index += "(" + (notes.indexOf(note) + 1) + ")  ";
        }

        TextView textView_specific_note_index = new TextView(this);
        textView_specific_note_index.setText(index);
        textView_specific_note_index.setSingleLine(false);
        textView_specific_note_index.setTextColor(Color.BLACK);
        textView_specific_note_index.setTextSize(15);
        textView_specific_note_index.setTypeface(Typeface.SANS_SERIF);
        if (screenWidth >= 600 && screenWidth < 720) {
            TableRow.LayoutParams paramsSpecificNoteIndex = new TableRow.LayoutParams(150,
                    TableRow.LayoutParams.WRAP_CONTENT);
            paramsSpecificNoteIndex.gravity = Gravity.CENTER;
            dose_data.addView(textView_specific_note_index, paramsSpecificNoteIndex);
        } else if (screenWidth >= 720) {
            TableRow.LayoutParams paramsSpecificNoteIndex = new TableRow.LayoutParams(
                    TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
            paramsSpecificNoteIndex.gravity = Gravity.CENTER;
            dose_data.addView(textView_specific_note_index, paramsSpecificNoteIndex);
        } else {
            TableRow.LayoutParams paramsSpecificNoteIndex = new TableRow.LayoutParams(100,
                    TableRow.LayoutParams.WRAP_CONTENT);
            paramsSpecificNoteIndex.gravity = Gravity.CENTER;
            if ((screenWidth < 600 && !isCollapsed(drug_name, group_name, animal_family, "Note"))
                    || screenWidth >= 600)
                dose_data.addView(textView_specific_note_index, paramsSpecificNoteIndex);
        }

        dose_table.addView(dose_data);

    }
}

From source file:com.vonglasow.michael.satstat.RadioSectionFragment.java

protected void showCellLte(CellTowerLte cell) {
    TableRow row = new TableRow(rilLteCells.getContext());
    row.setWeightSum(29);/* w w w  .  j  a  v  a2  s  . com*/

    TextView newType = new TextView(rilLteCells.getContext());
    newType.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2));
    newType.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newType.setTextColor(
            rilLteCells.getContext().getResources().getColor(getColorFromGeneration(cell.getGeneration())));
    newType.setText(rilLteCells.getContext().getResources().getString(R.string.smallDot));
    row.addView(newType);

    TextView newMcc = new TextView(rilLteCells.getContext());
    newMcc.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
    newMcc.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newMcc.setText(formatCellData(rilLteCells.getContext(), "%03d", cell.getMcc()));
    row.addView(newMcc);

    TextView newMnc = new TextView(rilLteCells.getContext());
    newMnc.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
    newMnc.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newMnc.setText(formatCellData(rilLteCells.getContext(), "%02d", cell.getMnc()));
    row.addView(newMnc);

    TextView newTac = new TextView(rilLteCells.getContext());
    newTac.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 5));
    newTac.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newTac.setText(formatCellData(rilLteCells.getContext(), null, cell.getTac()));
    row.addView(newTac);

    TextView newCi = new TextView(rilLteCells.getContext());
    newCi.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 9));
    newCi.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    if ((mainActivity.prefCid) && (cell.getCi() != CellTower.UNKNOWN)) {
        int eNodeBId = cell.getCi() / 0x100;
        int sectorId = cell.getCi() % 0x100;
        newCi.setText(String.format("%d-%d", eNodeBId, sectorId));
    } else
        newCi.setText(formatCellData(rilLteCells.getContext(), null, cell.getCi()));
    row.addView(newCi);

    TextView newPci = new TextView(rilLteCells.getContext());
    newPci.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
    newPci.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newPci.setText(formatCellData(rilLteCells.getContext(), null, cell.getPci()));
    row.addView(newPci);

    TextView newDbm = new TextView(rilLteCells.getContext());
    newDbm.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 4));
    newDbm.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newDbm.setText(formatCellDbm(rilLteCells.getContext(), null, cell.getDbm()));
    row.addView(newDbm);

    rilLteCells.addView(row,
            new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}

From source file:com.vonglasow.michael.satstat.MainActivity.java

private final void addWifiResult(ScanResult result) {
    final ScanResult r = result;
    android.view.View.OnClickListener clis = new android.view.View.OnClickListener() {

        @Override/*from  w w w . jav  a 2 s  . c o m*/
        public void onClick(View v) {
            onWifiEntryClick(r.BSSID);
        }
    };

    View divider = new View(wifiAps.getContext());
    divider.setLayoutParams(new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, 1));
    divider.setBackgroundColor(getResources().getColor(android.R.color.tertiary_text_dark));
    divider.setOnClickListener(clis);
    wifiAps.addView(divider);

    LinearLayout wifiLayout = new LinearLayout(wifiAps.getContext());
    wifiLayout.setLayoutParams(
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    wifiLayout.setOrientation(LinearLayout.HORIZONTAL);
    wifiLayout.setWeightSum(22);
    wifiLayout.setMeasureWithLargestChildEnabled(false);

    ImageView wifiType = new ImageView(wifiAps.getContext());
    wifiType.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.MATCH_PARENT, 3));
    if (WifiCapabilities.isAdhoc(result)) {
        wifiType.setImageResource(R.drawable.ic_content_wifi_adhoc);
    } else if ((WifiCapabilities.isEnterprise(result))
            || (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.EAP)) {
        wifiType.setImageResource(R.drawable.ic_content_wifi_eap);
    } else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.PSK) {
        wifiType.setImageResource(R.drawable.ic_content_wifi_psk);
    } else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.WEP) {
        wifiType.setImageResource(R.drawable.ic_content_wifi_wep);
    } else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.OPEN) {
        wifiType.setImageResource(R.drawable.ic_content_wifi_open);
    } else {
        wifiType.setImageResource(R.drawable.ic_content_wifi_unknown);
    }

    wifiType.setScaleType(ScaleType.CENTER);
    wifiLayout.addView(wifiType);

    TableLayout wifiDetails = new TableLayout(wifiAps.getContext());
    wifiDetails.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 19));
    TableRow innerRow1 = new TableRow(wifiAps.getContext());
    TextView newMac = new TextView(wifiAps.getContext());
    newMac.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 14));
    newMac.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium);
    newMac.setText(result.BSSID);
    innerRow1.addView(newMac);
    TextView newCh = new TextView(wifiAps.getContext());
    newCh.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2));
    newCh.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium);
    newCh.setText(getChannelFromFrequency(result.frequency));
    innerRow1.addView(newCh);
    TextView newLevel = new TextView(wifiAps.getContext());
    newLevel.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
    newLevel.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium);
    newLevel.setText(String.valueOf(result.level));
    innerRow1.addView(newLevel);
    innerRow1.setOnClickListener(clis);
    wifiDetails.addView(innerRow1,
            new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    TableRow innerRow2 = new TableRow(wifiAps.getContext());
    TextView newSSID = new TextView(wifiAps.getContext());
    newSSID.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 19));
    newSSID.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Small);
    newSSID.setText(result.SSID);
    innerRow2.addView(newSSID);
    innerRow2.setOnClickListener(clis);
    wifiDetails.addView(innerRow2,
            new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    wifiLayout.addView(wifiDetails);
    wifiLayout.setOnClickListener(clis);
    wifiAps.addView(wifiLayout);
}

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

private TableRow constructRow(Context context, float weightSum) {
    final TableRow row = new TableRow(context);
    row.setId(ElementsIdProvider.getNextId());
    row.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    row.setWeightSum(weightSum);//from w  w w.j a  v a2s. c o m
    return row;
}

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

/**
 * Create table to show data in a table/*from  w  w w. j a  v a  2s  .  c o 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.adarshahd.indianrailinfo.donate.TrainDetails.java

private void createTableLayoutTrainAvailability() {

    if (mPage.contains("SORRY")) {
        TextView textViewTrnDtls = new TextView(mActivity);
        textViewTrnDtls.setText("Not a valid class, Please select a different class and try again.");
        textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large);
        textViewTrnDtls.setPadding(10, 10, 10, 10);
        textViewTrnDtls.setTextColor(Color.RED);
        mFrameLayout.removeAllViews();/*from   w w  w.j a v  a 2 s .  c o m*/
        mFrameLayout.addView(textViewTrnDtls);
        if (mDialog.isShowing()) {
            mDialog.cancel();
        }
        return;
    }

    if (mPage.contains("ISL Of")) {
        TextView textViewTrnDtls = new TextView(mActivity);
        textViewTrnDtls.setText("Station is not in ISL Of the Train. \nPlease modify the source/destination!");
        textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large);
        textViewTrnDtls.setPadding(10, 10, 10, 10);
        textViewTrnDtls.setTextColor(Color.RED);
        mFrameLayout.removeAllViews();
        mFrameLayout.addView(textViewTrnDtls);
        if (mDialog.isShowing()) {
            mDialog.cancel();
        }
        return;
    }

    if (mPage.contains("ERROR")) {
        TextView textViewTrnDtls = new TextView(mActivity);
        textViewTrnDtls.setText("Your request resulted in an error.\nPlease check!");
        textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large);
        textViewTrnDtls.setPadding(10, 10, 10, 10);
        textViewTrnDtls.setTextColor(Color.RED);
        mFrameLayout.removeAllViews();
        mFrameLayout.addView(textViewTrnDtls);
        if (mDialog.isShowing()) {
            mDialog.cancel();
        }
        return;
    }

    if (mPage.contains("Network Connectivity")) {
        TextView textViewTrnDtls = new TextView(mActivity);
        textViewTrnDtls.setText("Looks like the server is busy.\nPlease try later!");
        textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large);
        textViewTrnDtls.setPadding(10, 10, 10, 10);
        textViewTrnDtls.setTextColor(Color.RED);
        mFrameLayout.removeAllViews();
        mFrameLayout.addView(textViewTrnDtls);
        if (mDialog.isShowing()) {
            mDialog.cancel();
        }
        return;
    }

    if (mPage.contains("unavailable")) {
        TextView textViewTrnDtls = new TextView(mActivity);
        textViewTrnDtls.setText(
                "Response from server:\n\nYour request could not be processed now.\nPlease try again later!");
        textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large);
        textViewTrnDtls.setPadding(10, 10, 10, 10);
        textViewTrnDtls.setTextColor(Color.RED);
        mFrameLayout.removeAllViews();
        mFrameLayout.addView(textViewTrnDtls);
        if (mDialog.isShowing()) {
            mDialog.cancel();
        }
        return;
    }

    if (mDetails == null || !mDetails.getTrainNumber().equals(mTrainNumber)) {
        Iterator iterator = null;
        try {
            iterator = mElements.first().parent().parent().parent().getElementsByTag("tr").iterator();
        } catch (Exception e) {
            Log.i("TrainDetails", mPage);
            e.printStackTrace();
            return;
        }
        mListAv = new ArrayList<List<String>>();
        List<String> list;
        Element tmp;
        tmp = (Element) iterator.next();
        list = new ArrayList<String>();
        list.add(tmp.select("th").get(0).text());
        list.add("Date");
        list.add(tmp.select("th").get(2).text());
        //list.add(tmp.select("th").get(3).text());
        mListAv.add(list);
        while (iterator.hasNext()) {
            tmp = (Element) iterator.next();
            if (!tmp.hasText()) {
                continue;
            }
            list = new ArrayList<String>();
            list.add(tmp.select("td").get(0).text());
            list.add(tmp.select("td").get(1).text());
            list.add(tmp.select("td").get(2).text());
            //list.add(tmp.select("td").get(3).text());
            mListAv.add(list);
        }
        mDetails = new Details(mListAv, TrainEnquiry.AVAILABILITY, mTrainNumber);
    } else {
        mListAv = mDetails.getList();
    }
    mTblLayoutAv = new TableLayout(mActivity);
    TableRow row;
    TextView tv1, tv2, tv3;
    mTblLayoutAv.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    for (int i = 0; i < mListAv.size(); i++) {
        row = new TableRow(mActivity);
        tv1 = new TextView(mActivity);
        tv2 = new TextView(mActivity);
        tv3 = new TextView(mActivity);
        //tv4 = new TextView(mActivity);

        tv1.setText("   " + mListAv.get(i).get(0));
        tv2.setText("   " + mListAv.get(i).get(1));
        tv3.setText("   " + mListAv.get(i).get(2));
        //tv4.setText("   " + mListAv.get(i).get(3));

        tv1.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium);
        tv2.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium);
        tv3.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium);
        //tv4.setTextAppearance(mActivity,android.R.style.TextAppearance_DeviceDefault_Medium);

        tv1.setPadding(5, 5, 5, 5);
        tv2.setPadding(5, 5, 5, 5);
        tv3.setPadding(5, 5, 5, 5);
        //tv4.setPadding(5,5,5,5);

        /*tv2.setBackgroundResource(R.drawable.card_divider);
        tv3.setBackgroundResource(R.drawable.card_divider);
        tv4.setBackgroundResource(R.drawable.card_divider);*/

        row.addView(tv1);
        row.addView(tv2);
        row.addView(tv3);
        //row.addView(tv4);

        row.setBackgroundResource(R.drawable.button_selector);
        row.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
        row.setOnClickListener(this);
        mTblLayoutAv.addView(row);
    }
    LinearLayout ll = new LinearLayout(mActivity);
    ScrollView scrollView = new ScrollView(mActivity);
    TextView textViewTrnDtls = new TextView(mActivity);
    textViewTrnDtls.setText("Availability details:");
    textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large);
    textViewTrnDtls.setPadding(10, 10, 10, 10);
    ll.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    ll.setOrientation(LinearLayout.VERTICAL);
    ll.addView(textViewTrnDtls);
    ll.addView(mTblLayoutAv);
    scrollView.addView(ll);
    mFrameLayout.removeAllViews();
    mFrameLayout.addView(scrollView);
    if (mDialog.isShowing()) {
        mDialog.cancel();
    }
}

From source file:com.cybrosys.scientific.EventListener.java

@SuppressWarnings("deprecation")
public void showHistory() {
    shPref = ScientificActivity.ctx.getSharedPreferences("myHistpref", 0);
    int inSize = shPref.getInt("HistIndex", 0);
    System.out.println("" + inSize);
    String[] str = new String[inSize];
    for (int inI = 0; inI < inSize; inI++) {
        str[inI] = shPref.getString("hist" + inI, "");
        System.out.println(str[inI]);
    }//from   w  w  w.j a  v  a2s.com
    LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    vwLayout = inflater.inflate(R.layout.pop_history,
            (ViewGroup) ((Activity) ctx).findViewById(R.id.popup_element));

    popmW1 = new PopupWindow(vwLayout, PalmCalcActivity.inDispwidth, PalmCalcActivity.inDispheight, true);
    popmW1.setBackgroundDrawable(new BitmapDrawable());
    popmW1.setOutsideTouchable(true);
    popmW1.showAtLocation(vwLayout, Gravity.CENTER, 0, 0);
    tblltTable = (TableLayout) vwLayout.findViewById(R.id.tablelay);
    ImageButton btnCancel = (ImageButton) vwLayout.findViewById(R.id.butcancelmain);
    btnCancel.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            popmW1.dismiss();

        }
    });
    txtvHistory = new TextView[inSize];
    btnHistory = new Button[inSize];
    tblrRowL = new TableRow[inSize];
    TableRow.LayoutParams buttonParams = new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT,
            TableRow.LayoutParams.WRAP_CONTENT, 1f);
    TableRow.LayoutParams textParams = new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT,
            TableRow.LayoutParams.WRAP_CONTENT, .1f);
    int inJ = 0, inL = inSize - 1;
    for (int inI = 0; inI < inSize; inI++) {
        if (!str[inI].equalsIgnoreCase("")) {
            btnHistory[inJ] = new Button(ctx);
            txtvHistory[inJ] = new TextView(ctx);
            txtvHistory[inJ].setText("" + (inJ + 1));
            txtvHistory[inJ].setGravity(Gravity.CENTER);
            txtvHistory[inJ].setTextColor(ScientificActivity.ctx.getResources().getColor(R.color.HistColor));
            txtvHistory[inJ].setLayoutParams(textParams);
            btnHistory[inJ].setText(str[inL]);
            btnHistory[inJ].setTextColor(Color.WHITE);
            btnHistory[inJ].setGravity(Gravity.LEFT);
            btnHistory[inJ].setLayoutParams(buttonParams);
            btnHistory[inJ].setBackgroundDrawable(ctx.getResources().getDrawable(R.drawable.button_effect));
            tblrRowL[inJ] = new TableRow(ctx);
            tblrRowL[inJ].addView(txtvHistory[inJ]);
            tblrRowL[inJ].addView(btnHistory[inJ]);
            tblltTable.addView(tblrRowL[inJ]);
            final int inK = inJ;
            btnHistory[inK].setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    // etxt.setText(btns[inK].getText().toString());
                    mHandler.insert(btnHistory[inK].getText().toString());
                    popmW1.dismiss();
                }
            });

            inJ++;
            inL--;
        }

    }
    if (inSize == 0) {
        TextView txtvHistory = new TextView(ctx);
        txtvHistory.setLayoutParams(textParams);
        txtvHistory.setGravity(Gravity.CENTER);
        txtvHistory.setTextColor(Color.WHITE);
        txtvHistory.setText("History Empty");
        TableRow tblrRowL = new TableRow(ctx);
        tblrRowL.addView(txtvHistory);
        tblltTable.addView(tblrRowL);
    }
}

From source file:edu.cens.loci.ui.PlaceViewActivity.java

private void updateWifiList(TableLayout table, LociWifiFingerprint wifi) {

    ArrayList<WifiViewListItem> items = new ArrayList<WifiViewListItem>();

    HashMap<String, APInfoMapItem> apMap = wifi.getAps();
    Set<String> keys = apMap.keySet();
    Iterator<String> iter = keys.iterator();
    while (iter.hasNext()) {
        String bssid = iter.next();
        APInfoMapItem ap = apMap.get(bssid);
        items.add(new WifiViewListItem(bssid, ap.ssid, ap.rss, ap.count, ap.rssBuckets));
    }/*from   w  w  w . jav  a2s  . co m*/

    Collections.sort(items);

    table.setColumnCollapsed(0, false);
    table.setColumnCollapsed(1, true);
    table.setColumnShrinkable(0, true);

    for (int i = 0; i < mAddedRows.size(); i++) {
        table.removeView(mAddedRows.get(i));
    }
    mAddedRows.clear();

    int totalCount = wifi.getScanCount();

    for (WifiViewListItem item : items) {
        TableRow row = new TableRow(this);

        TextView ssidView = new TextView(this);
        ssidView.setText(item.ssid);
        //ssidView.setText("very very very veryvery very very very very very");
        ssidView.setPadding(2, 2, 2, 2);
        ssidView.setTextColor(0xffffffff);

        TextView bssidView = new TextView(this);
        bssidView.setText(item.bssid);
        bssidView.setPadding(2, 2, 2, 2);
        bssidView.setTextColor(0xffffffff);

        TextView cntView = new TextView(this);
        cntView.setText("" + (item.count * 100) / totalCount);
        cntView.setPadding(2, 2, 2, 2);
        cntView.setGravity(Gravity.CENTER);
        cntView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);

        TextView rssView = new TextView(this);
        rssView.setText("" + item.rss);
        rssView.setPadding(2, 2, 6, 2);
        rssView.setGravity(Gravity.CENTER);
        rssView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);

        row.addView(ssidView, new TableRow.LayoutParams(0));
        row.addView(bssidView, new TableRow.LayoutParams(1));
        row.addView(cntView, new TableRow.LayoutParams(2));
        row.addView(rssView, new TableRow.LayoutParams(3));

        //Log.d(TAG, item.ssid);
        for (int i = 0; i < item.rssBuckets.length; i++) {
            TextView box = new TextView(this);
            box.setText("  ");
            box.setGravity(Gravity.RIGHT);
            box.setPadding(2, 2, 2, 2);
            box.setHeight(15);
            box.setGravity(Gravity.CENTER_VERTICAL);

            float colorVal = 256 * ((float) item.rssBuckets[i] / (float) wifi.getScanCount());
            //Log.d(TAG, "colorVal=" + (int) colorVal + ", " + item.histogram[i]);
            int colorValInt = ((int) colorVal) - 1;
            if (colorValInt < 0)
                colorValInt = 0;

            box.setBackgroundColor(0xff000000 + colorValInt);//+ 0x000000ff * (item.histogram[i]/totScan));
            box.setTextColor(0xffffffff);

            row.addView(box, new TableRow.LayoutParams(4 + i));
        }

        row.setGravity(Gravity.CENTER);

        table.addView(row, new TableLayout.LayoutParams());
        table.setColumnStretchable(3, true);
        mAddedRows.add(row);
    }

}