List of usage examples for android.widget TableLayout addView
@Override public void addView(View child, ViewGroup.LayoutParams params)
From source file:com.example.hllut.app.Deprecated.MainActivity.java
/** * Fills "amount of planets" textView as well as drawing the planets *//* w ww . j a va 2 s . c o m*/ private void drawPlanets() { //TODO use the bundle int numberOfPlanets = (int) (TOTAL_CO2 / MAX_CO2_PER_PERSON); TextView need = (TextView) findViewById(R.id.planetsTextView); need.setText("We would need " + numberOfPlanets + " planets"); TableLayout layout = (TableLayout) findViewById(R.id.planetContainer); TableRow tbr = new TableRow(this); LinearLayout linearLayout = new LinearLayout(this); linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1f)); //TODO tbr.setLayoutParams( new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT)); tbr.setPadding(10, 10, 10, 10); for (int i = 1; i < numberOfPlanets + 1; i++) { // TODO: Too many planets fuck up formatting // Create images ImageView im = new ImageView(this); im.setImageResource(R.drawable.earth); im.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f)); im.setPadding(10, 10, 10, 10); //planets per row = 5 if (i % 5 == 0) { // if you have gone 5 laps // print what you have linearLayout.addView(im); tbr.addView(linearLayout, new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1f)); layout.addView(tbr, new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.MATCH_PARENT)); tbr = new TableRow(this); linearLayout = new LinearLayout(this); linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, 1f)); tbr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT)); tbr.setPadding(10, 10, 10, 10); } else { linearLayout.addView(im); } } tbr.addView(linearLayout, new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1f)); // layout.addView(tbr, new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.MATCH_PARENT)); }
From source file:com.vonglasow.michael.satstat.ui.RadioSectionFragment.java
private final void addWifiResult(ScanResult result) { // needed to pass a persistent reference to the OnClickListener final ScanResult r = result; android.view.View.OnClickListener clis = new android.view.View.OnClickListener() { @Override/* w w w. j av a2s. c o m*/ public void onClick(View v) { onWifiEntryClick(r.BSSID); } }; 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:com.mifos.utils.DataTableUIBuilder.java
public LinearLayout getDataTableLayout(final DataTable dataTable, JsonArray jsonElements, LinearLayout parentLayout, final Context context, final int entityId, DataTableActionListener mListener) { dataTableActionListener = mListener; /**/*from w w w.j a va 2s . c o m*/ * Create a Iterator with Json Elements to Iterate over the DataTable * Response. */ Iterator<JsonElement> jsonElementIterator = jsonElements.iterator(); /* * Each Row of the Data Table is Treated as a Table Here. * Creating the First Table for First Row */ tableIndex = 0; while (jsonElementIterator.hasNext()) { TableLayout tableLayout = new TableLayout(context); tableLayout.setPadding(10, 10, 10, 10); final JsonElement jsonElement = jsonElementIterator.next(); /* * Each Entry in a Data Table is Displayed in the * form of a table where each row contains one Key-Value Pair * i.e a Column Name - Column Value from the DataTable */ int rowIndex = 0; while (rowIndex < dataTable.getColumnHeaderData().size()) { TableRow tableRow = new TableRow(context); tableRow.setLayoutParams(new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); tableRow.setPadding(10, 10, 10, 10); if (rowIndex % 2 == 0) { tableRow.setBackgroundColor(Color.LTGRAY); } else { tableRow.setBackgroundColor(Color.WHITE); } TextView key = new TextView(context); key.setText(dataTable.getColumnHeaderData().get(rowIndex).getColumnName()); key.setGravity(Gravity.LEFT); TextView value = new TextView(context); value.setGravity(Gravity.RIGHT); if (jsonElement.getAsJsonObject().get(dataTable.getColumnHeaderData().get(rowIndex).getColumnName()) .toString().contains("\"")) { value.setText(jsonElement.getAsJsonObject() .get(dataTable.getColumnHeaderData().get(rowIndex).getColumnName()).toString() .replace("\"", "")); } else { value.setText(jsonElement.getAsJsonObject() .get(dataTable.getColumnHeaderData().get(rowIndex).getColumnName()).toString()); } tableRow.addView(key, new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1f)); tableRow.addView(value, new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1f)); TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); layoutParams.setMargins(12, 16, 12, 16); tableLayout.addView(tableRow, layoutParams); rowIndex++; } tableLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(context, "Update Row " + tableIndex, Toast.LENGTH_SHORT).show(); } }); tableLayout.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Toast.makeText(context, "Deleting Row " + tableIndex, Toast.LENGTH_SHORT).show(); BaseApiManager baseApiManager = new BaseApiManager(); DataManager dataManager = new DataManager(baseApiManager); Observable<GenericResponse> call = dataManager .removeDataTableEntry(dataTable.getRegisteredTableName(), entityId, Integer.parseInt(jsonElement.getAsJsonObject() .get(dataTable.getColumnHeaderData().get(0).getColumnName()) .toString())); Subscription subscription = call.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()).subscribe(new Subscriber<GenericResponse>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { } @Override public void onNext(GenericResponse genericResponse) { Toast.makeText(context, "Deleted Row " + tableIndex, Toast.LENGTH_SHORT).show(); dataTableActionListener.onRowDeleted(); } }); return true; } }); View v = new View(context); v.setBackgroundColor(ContextCompat.getColor(context, R.color.black)); parentLayout.addView(tableLayout); parentLayout.addView(v, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 5)); Log.i("TABLE INDEX", "" + tableIndex); tableIndex++; } return parentLayout; }
From source file:org.totschnig.myexpenses.activity.ExpenseEdit.java
private void switchAccountViews() { Spinner accountSpinner = mAccountSpinner.getSpinner(); Spinner transferAccountSpinner = mTransferAccountSpinner.getSpinner(); ViewGroup accountParent = (ViewGroup) findViewById(R.id.AccountRow); ViewGroup transferAccountRow = (ViewGroup) findViewById(R.id.TransferAccountRow); TableLayout table = (TableLayout) findViewById(R.id.Table); View amountRow = table.findViewById(R.id.AmountRow); View transferAmountRow = table.findViewById(R.id.TransferAmountRow); table.removeView(amountRow);//from w w w .j a v a2 s . c om table.removeView(transferAmountRow); if (mType == INCOME) { accountParent.removeView(accountSpinner); transferAccountRow.removeView(transferAccountSpinner); accountParent.addView(transferAccountSpinner); transferAccountRow.addView(accountSpinner); table.addView(transferAmountRow, 2); table.addView(amountRow, 4); } else { accountParent.removeView(transferAccountSpinner); transferAccountRow.removeView(accountSpinner); accountParent.addView(accountSpinner); transferAccountRow.addView(transferAccountSpinner); table.addView(amountRow, 2); table.addView(transferAmountRow, 4); } linkAccountLabels(); }
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// w w w. j av a 2 s . co 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:com.amsterdam.marktbureau.makkelijkemarkt.DagvergunningFragment.java
/** * Populate overzicht fragment from local member vars *//*w w w.j av a 2 s . c o m*/ private void populateOverzichtFragment() { if (mOverzichtFragmentReady) { // TODO: show the changes in case we are editing an existing dagvergunning // koopman if (mKoopmanId > 0) { mOverzichtFragment.mKoopmanLinearLayout.setVisibility(View.VISIBLE); mOverzichtFragment.mKoopmanEmptyTextView.setVisibility(View.GONE); // koopman details mOverzichtFragment.setKoopman(mKoopmanId); // dagvergunning registratie tijd if (mRegistratieDatumtijd != null) { try { Date registratieDate = new SimpleDateFormat(getString(R.string.date_format_datumtijd), Locale.getDefault()).parse(mRegistratieDatumtijd); SimpleDateFormat sdf = new SimpleDateFormat(getString(R.string.date_format_tijd)); String registratieTijd = sdf.format(registratieDate); mOverzichtFragment.mRegistratieDatumtijdText.setText(registratieTijd); } catch (java.text.ParseException e) { Utility.log(getContext(), LOG_TAG, "Format registratie tijd failed: " + e.getMessage()); } } else { mOverzichtFragment.mRegistratieDatumtijdText.setText(""); } // dagvergunning notitie if (mNotitie != null && !mNotitie.equals("")) { mOverzichtFragment.mNotitieText.setText(getString(R.string.label_notitie) + ": " + mNotitie); Utility.collapseView(mOverzichtFragment.mNotitieText, false); } else { Utility.collapseView(mOverzichtFragment.mNotitieText, true); } // dagvergunning totale lengte if (mTotaleLengte != -1) { mOverzichtFragment.mTotaleLengte .setText(mTotaleLengte + " " + getString(R.string.length_meter)); } // registratie account naam if (mRegistratieAccountNaam != null) { mOverzichtFragment.mAccountNaam.setText(mRegistratieAccountNaam); } else { mOverzichtFragment.mAccountNaam.setText(""); } // koopman aanwezig status if (mKoopmanAanwezig != null) { // get the corresponding aanwezig title from the resource array based on the aanwezig key String[] aanwezigKeys = getResources().getStringArray(R.array.array_aanwezig_key); String[] aanwezigTitles = getResources().getStringArray(R.array.array_aanwezig_title); String aanwezigTitle = ""; for (int i = 0; i < aanwezigKeys.length; i++) { if (aanwezigKeys[i].equals(mKoopmanAanwezig)) { aanwezigTitle = aanwezigTitles[i]; } } mOverzichtFragment.mAanwezigText.setText(aanwezigTitle); } // vervanger if (mVervangerId > 0) { // hide the aanwezig status and populate and show the vervanger details mOverzichtFragment.mAanwezigText.setVisibility(View.GONE); mOverzichtFragment.mVervangerDetail.setVisibility(View.VISIBLE); mOverzichtFragment.setVervanger(mVervangerId); } else { // show the aanwezig status and hide the vervanger details mOverzichtFragment.mAanwezigText.setVisibility(View.VISIBLE); mOverzichtFragment.mVervangerDetail.setVisibility(View.GONE); } } else { mOverzichtFragment.mKoopmanEmptyTextView.setVisibility(View.VISIBLE); mOverzichtFragment.mKoopmanLinearLayout.setVisibility(View.GONE); } // product if (mErkenningsnummer != null && isProductSelected()) { // show progress bar mProgressbar.setVisibility(View.VISIBLE); // disable save function until we have a response from the api for a concept factuur mConceptFactuurDownloaded = false; // post the dagvergunning details to the api and retrieve a concept 'factuur' ApiPostDagvergunningConcept postDagvergunningConcept = new ApiPostDagvergunningConcept( getContext()); postDagvergunningConcept.setPayload(dagvergunningToJson()); postDagvergunningConcept.enqueue(new Callback<JsonObject>() { @Override public void onResponse(Response<JsonObject> response) { // hide progress bar mProgressbar.setVisibility(View.GONE); if (response.isSuccess() && response.body() != null) { mOverzichtFragment.mProductenLinearLayout.setVisibility(View.VISIBLE); mOverzichtFragment.mProductenEmptyTextView.setVisibility(View.GONE); // enable save function and give wizard next button background enabled color mConceptFactuurDownloaded = true; mWizardNextButton .setBackgroundColor(ContextCompat.getColor(getContext(), R.color.accent)); // from the response, populate the product section of the overzicht fragment View overzichtView = mOverzichtFragment.getView(); if (overzichtView != null) { // find placeholder table layout view TableLayout placeholderLayout = (TableLayout) overzichtView .findViewById(R.id.producten_placeholder); if (placeholderLayout != null) { placeholderLayout.removeAllViews(); LayoutInflater layoutInflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); // get the producten array JsonArray producten = response.body().getAsJsonArray(getString( R.string.makkelijkemarkt_api_dagvergunning_concept_producten)); if (producten != null) { int rowCount = 0; // table header View headerLayout = layoutInflater .inflate(R.layout.dagvergunning_overzicht_product_item, null); TextView btwHeaderText = (TextView) headerLayout .findViewById(R.id.btw_totaal); btwHeaderText.setText("BTW"); TextView exclusiefHeaderText = (TextView) headerLayout .findViewById(R.id.bedrag_totaal); exclusiefHeaderText.setText("Ex. BTW"); placeholderLayout.addView(headerLayout, rowCount++); for (int i = 0; i < producten.size(); i++) { JsonObject product = producten.get(i).getAsJsonObject(); // get the product item layout View childLayout = layoutInflater .inflate(R.layout.dagvergunning_overzicht_product_item, null); // aantal if (product.get("aantal") != null && !product.get("aantal").isJsonNull()) { TextView aantalText = (TextView) childLayout .findViewById(R.id.product_aantal); aantalText.setText(product.get("aantal").getAsInt() + " x "); } // naam if (product.get("naam") != null && !product.get("naam").isJsonNull()) { TextView naamText = (TextView) childLayout .findViewById(R.id.product_naam); naamText.setText( Utility.capitalize(product.get("naam").getAsString())); } // btw % if (product.get("btw_percentage") != null && !product.get("btw_percentage").isJsonNull()) { long btwPercentage = Math.round(Double .parseDouble(product.get("btw_percentage").getAsString())); if (btwPercentage != 0) { TextView btwPercentageText = (TextView) childLayout .findViewById(R.id.btw_percentage); btwPercentageText.setText(btwPercentage + "%"); } } // btw totaal if (product.get("btw_totaal") != null && !product.get("btw_totaal").isJsonNull()) { double btwTotaalProduct = Double .parseDouble(product.get("btw_totaal").getAsString()); TextView btwTotaalText = (TextView) childLayout .findViewById(R.id.btw_totaal); if (Math.round(btwTotaalProduct) != 0) { btwTotaalText .setText(String.format(" %.2f", btwTotaalProduct)); } else { btwTotaalText.setText("-"); } } // bedrag totaal if (product.get("totaal") != null && !product.get("totaal").isJsonNull()) { double bedragTotaal = Double .parseDouble(product.get("totaal").getAsString()); TextView bedragTotaalText = (TextView) childLayout .findViewById(R.id.bedrag_totaal); bedragTotaalText.setText(String.format(" %.2f", bedragTotaal)); } // add child view placeholderLayout.addView(childLayout, rowCount++); } // exclusief double exclusief = 0; if (response.body().get("exclusief") != null && !response.body().get("exclusief").isJsonNull()) { exclusief = Double .parseDouble(response.body().get("exclusief").getAsString()); } // totaal double totaal = 0; if (response.body().get("totaal") != null && !response.body().get("totaal").isJsonNull()) { totaal = response.body().get("totaal").getAsDouble(); } // totaal btw en ex. btw View totaalLayout = layoutInflater .inflate(R.layout.dagvergunning_overzicht_product_item, null); TextView naamText = (TextView) totaalLayout.findViewById(R.id.product_naam); naamText.setText("Totaal"); TextView btwTotaalText = (TextView) totaalLayout .findViewById(R.id.btw_totaal); if (Math.round(totaal - exclusief) != 0) { btwTotaalText.setText(String.format(" %.2f", (totaal - exclusief))); } TextView exclusiefText = (TextView) totaalLayout .findViewById(R.id.bedrag_totaal); exclusiefText.setText(String.format(" %.2f", exclusief)); placeholderLayout.addView(totaalLayout, rowCount++); // separator View emptyLayout = layoutInflater .inflate(R.layout.dagvergunning_overzicht_product_item, null); placeholderLayout.addView(emptyLayout, rowCount++); // totaal inc. btw View totaalIncLayout = layoutInflater .inflate(R.layout.dagvergunning_overzicht_product_item, null); TextView totaalNaamText = (TextView) totaalIncLayout .findViewById(R.id.product_naam); totaalNaamText.setText("Totaal inc. BTW"); TextView totaalIncText = (TextView) totaalIncLayout .findViewById(R.id.bedrag_totaal); totaalIncText.setText(String.format(" %.2f", totaal)); placeholderLayout.addView(totaalIncLayout, rowCount); } } } } } @Override public void onFailure(Throwable t) { mProgressbar.setVisibility(View.GONE); } }); } else { mOverzichtFragment.mProductenLinearLayout.setVisibility(View.GONE); if (mKoopmanId > 0) { mOverzichtFragment.mProductenEmptyTextView.setVisibility(View.VISIBLE); } } } }
From source file:edu.cens.loci.ui.widget.GenericEditorView.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)); }//ww w . j a v a 2 s.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(); Context context = getContext(); for (WifiViewListItem item : items) { TableRow row = new TableRow(context); TextView ssidView = new TextView(context); 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(context); bssidView.setText(item.bssid); bssidView.setPadding(2, 2, 2, 2); bssidView.setTextColor(0xffffffff); TextView cntView = new TextView(context); 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(context); 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(context); 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); } }
From source file:com.woofer.activity.personHomeActivity.java
public void showTable() { TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT); layoutParams.gravity = Gravity.LEFT; layoutParams.leftMargin = 30;//from w ww . ja va2 s. c om layoutParams.bottomMargin = 10; layoutParams.topMargin = 10; for (int i = 0; i < 30; i++) { TableRow tableRow = new TableRow(this); TextView textView7 = new TextView(this); textView7.setText("" + i); textView7.setTextSize(18); textView7.setTextColor(Color.rgb(0, 0, 0)); textView7.setPadding(15, 0, 15, 0); tableRow.addView(textView7, layoutParams); tableRow.setBackgroundColor(Color.WHITE); final int n = i; tableRow.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(personHomeActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show(); } }); mMainLayout.addView(tableRow); TableRow tableRow1 = new TableRow(this); TextView textView1 = new TextView(this); textView1.setText("Test pull down scrollvsfadasdsadsasadsadsadsadsadasdsadasdasdsadsaddasdiew " + i); textView1.setTextSize(16); textView1.setPadding(15, 0, 15, 15); tableRow1.addView(textView1, layoutParams); tableRow1.setBackgroundColor(Color.WHITE); tableRow.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(personHomeActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show(); } }); mMainLayout.addView(tableRow1); // TableRow tableRow2 = new TableRow(this); // //tableRow2.addView(textView2, layoutParams); // ImageView imageView = new ImageView(this); // imageView.setImageResource(R.drawable.icon_reply_t); // imageView.setScaleX((float) a); // imageView.setScaleY((float) a); // imageView.setPadding(0, 0, 0, 0); // // ImageView imageView1 = new ImageView(this); // imageView1.setImageResource(R.drawable.icon_thumb_t); // imageView1.setScaleX((float) a); // imageView1.setScaleY((float) a); // imageView1.setPadding(0, 0, 0, 0); // // // //tableRow2.addView(imageView); // tableRow2.addView(imageView1); // mMainLayout.addView(tableRow2); TableLayout mytable = (TableLayout) findViewById(R.id.degital_textTL); int numberOfRow = 1; int numberOfColumn = 12; int cellDimension = 24; int cellPadding = 200; for (int row = 0; row < numberOfRow; row++) { tableRow = new TableRow(this); //tableRow.setLayoutParams(new TableLayout.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,TableRow.LayoutParams.MATCH_PARENT)); tableRow.setLayoutParams(new TableLayout.LayoutParams( (cellDimension + 2 * cellPadding) * numberOfColumn, cellDimension + 2 * cellPadding)); for (int column = 0; column < numberOfColumn; column++) { if (column % 3 == 0) { TextView textView = new TextView(this); textView.setTextSize(20); textView.setText(" "); tableRow.addView(textView); } if (column % 3 == 1) { if (column == 1) { ImageView imageView = new ImageView(this); imageView.setScaleX((float) 0.5); imageView.setScaleY((float) 0.5); imageView.setImageResource(R.drawable.icon_eye_t); tableRow.addView(imageView); } if (column == 4) { ImageView imageView = new ImageView(this); imageView.setScaleX((float) 0.5); imageView.setScaleY((float) 0.5); imageView.setImageResource(R.drawable.icon_thumb_t); tableRow.addView(imageView); } if (column == 7) { ImageView imageView = new ImageView(this); imageView.setScaleX((float) 0.5); imageView.setScaleY((float) 0.5); imageView.setImageResource(R.drawable.icon_reply_t); tableRow.addView(imageView); } if (column == 10) { ImageView imageView = new ImageView(this); imageView.setScaleX((float) 0.5); imageView.setScaleY((float) 0.5); imageView.setImageResource(R.drawable.icon_pencil_t); tableRow.addView(imageView); } } if (column % 3 == 2) { if (column == 2) { TextView textView = new TextView(this); textView.setText("8"); tableRow.addView(textView); } if (column == 5) { TextView textView = new TextView(this); textView.setText("8"); tableRow.addView(textView); } if (column == 8) { TextView textView = new TextView(this); textView.setText("8"); tableRow.addView(textView); } if (column == 11) { TextView textView = new TextView(this); textView.setText("8"); tableRow.addView(textView); } } } mytable.addView(tableRow, new TableLayout.LayoutParams( (cellDimension + 2 * cellPadding) * numberOfColumn, cellDimension + 2 * cellPadding)); //mytable.addView(tableRow,new TableLayout.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,TableRow.LayoutParams.MATCH_PARENT)); } } }
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)); }/* w w w. jav a 2s .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); } }
From source file:org.smilec.smile.student.CourseList.java
private void createScoreTable(Vector<Integer> _myscore, String username) { int num_right = countrightquestion(_myscore); int total_question = LAST_SCENE_NUM; TableLayout tl = (TableLayout) findViewById(R.id.tableLayoutSeeR); TextView text1 = (TextView) findViewById(R.id.Header01); text1.setText(getString(R.string.name) + ": " + username); TextView text2 = (TextView) findViewById(R.id.Header11); text2.setText(getString(R.string.t_score) + ":" + num_right + "/" + total_question); for (int i = 0; i < _myscore.size(); i++) { TableRow tr = new TableRow(getApplicationContext()); tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); int number = 0; number = i + 1;/* w w w. ja v a2 s. c om*/ int score = _myscore.get(i); Button b = new Button(getApplicationContext()); b.setText("(" + number + ")"); b.setTextSize(resultSize1); // b.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); TableRow.LayoutParams params = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); params.setMargins(returnPixels(30.0f), 0, returnPixels(30.0f), 0); b.setLayoutParams(params); b.setOnClickListener(new MyButtonListener(number)); /* Add Button to row. */ tr.addView(b); TextView text = new TextView(getApplicationContext()); if (score == 1) { // right text.setText("0"); } else { // wrong text.setText("X"); } text.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); text.setTextColor(Color.BLACK); text.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL); text.setTextSize(resultSize2); tr.addView(text); //tr.setBackgroundResource(R.drawable.sf_gradient_03); tl.addView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT)); } return; }