List of usage examples for android.widget TableRow addView
public void addView(View child)
Adds a child view.
From source file:net.naonedbus.card.impl.HoraireCard.java
private void fillView(final ViewGroup base, final ViewGroup parent) { final int viewsCount = getTextViewCount(base); final TableRow rowTop = (TableRow) parent.findViewById(R.id.rowTop); final TableRow rowBottom = (TableRow) parent.findViewById(R.id.rowBottom); for (int i = 0; i < viewsCount; i++) { int layoutHoraire; if (i == 0) layoutHoraire = R.layout.card_horaire_text_first; else if (i < viewsCount - 1) layoutHoraire = R.layout.card_horaire_text; else/*from www .jav a2 s. c o m*/ layoutHoraire = R.layout.card_horaire_text_last; final TextView horaireView = (TextView) mLayoutInflater.inflate(layoutHoraire, null); final TextView delayView = (TextView) mLayoutInflater.inflate(R.layout.card_horaire_delay, null); setTypefaceRobotoLight(horaireView); rowTop.addView(horaireView); rowBottom.addView(delayView); mHoraireViews.add(horaireView); mDelaiViews.add(delayView); } initLoader(null, this).forceLoad(); }
From source file:com.QuarkLabs.BTCeClient.fragments.HomeFragment.java
/** * Refreshes funds table with fetched data * * @param response JSONObject with funds data *//*from www . ja v a 2s .co 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:info.semanticsoftware.semassist.android.activity.SemanticResultsActivity.java
/** Presents the results in a list format. * @param savedInstanceState saved instance state *//*from ww w . j av a 2 s . c o m*/ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String resultsXML = getIntent().getStringExtra("xml"); Vector<SemanticServiceResult> results = ClientUtils.getServiceResults(resultsXML); setContentView(R.layout.results); TableLayout tblResults = (TableLayout) findViewById(R.id.tblResultsLayout); tblResults.setStretchAllColumns(true); TableRow resultRow; TextView txtContent; TextView txtType; TextView txtStart; TextView txtEnd; TextView txtFeats; if (results == null) { // handle server errors } else { for (SemanticServiceResult current : results) { if (current.mResultType.equals(SemanticServiceResult.ANNOTATION)) { List<AnnotationInstance> annots = ServerResponseHandler.createAnnotation(current); for (int i = 0; i < annots.size(); i++) { resultRow = new TableRow(getApplicationContext()); txtContent = new TextView(getApplicationContext()); txtContent.setText(annots.get(i).getContent()); txtContent.setTextAppearance(getApplicationContext(), R.style.normalText); resultRow.addView(txtContent); txtType = new TextView(getApplicationContext()); txtType.setText(annots.get(i).getType()); txtType.setTextAppearance(getApplicationContext(), R.style.normalText); resultRow.addView(txtType); txtStart = new TextView(getApplicationContext()); txtStart.setText(annots.get(i).getStart()); txtStart.setTextAppearance(getApplicationContext(), R.style.normalText); resultRow.addView(txtStart); txtEnd = new TextView(getApplicationContext()); txtEnd.setText(annots.get(i).getEnd()); txtEnd.setTextAppearance(getApplicationContext(), R.style.normalText); resultRow.addView(txtEnd); txtFeats = new TextView(getApplicationContext()); txtFeats.setText(annots.get(i).getFeatures()); txtFeats.setTextAppearance(getApplicationContext(), R.style.normalText); resultRow.addView(txtFeats); tblResults.addView(resultRow); } } else if (current.mResultType.equals(SemanticServiceResult.BOUNDLESS_ANNOTATION)) { //TODO find an actual pipeline to test this with } else if (current.mResultType.equals(SemanticServiceResult.FILE)) { fileName = current.mFileUrl; fileName = fileName.substring(fileName.lastIndexOf("/") + 1); Log.d(Constants.TAG, fileName); getFileContentTask task = new getFileContentTask(); task.execute(SemanticAssistantsActivity.serverURL); } } // reduce the number of allowed requests by one SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); String strReqNum = settings.getString("reqNum", "0"); try { int intReqNum = Integer.parseInt(strReqNum); Editor editor = settings.edit(); intReqNum--; editor.putString("reqNum", Integer.toString(intReqNum)); boolean result = editor.commit(); if (result) { Log.d(Constants.TAG, "Successfully reduced the reqNum"); } else { Log.d(Constants.TAG, "Cannot reduced the reqNum"); } } catch (Exception e) { System.err.println(e.getMessage()); } } //else }
From source file:com.hybris.mobile.app.commerce.fragment.ProductDetailFragmentBase.java
/** * Create table to show data in a table/*from ww w .j a v a2 s . 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:org.mythdroid.activities.Guide.java
/** * Get a spacer row// w ww .j av a2s . c o m * @return a spacer TableRow */ private TableRow getSpacer() { final TableRow row = new TableRow(this, null); LayoutParams params = new LayoutParams(); params.height = 1; row.setLayoutParams(params); View view = new View(this, null); params = new LayoutParams(); params.height = 1; params.width = chanWidth; params.column = 0; params.span = 1; view.setLayoutParams(params); row.addView(view); for (int i = 1; i < times.length; i++) { view = new View(this, null); view.setLayoutParams(spacerLayout); row.addView(view); } return row; }
From source file:ru.adios.budgeter.widgets.DataTableLayout.java
/** * Requires tableName to be checked, i.e. isPresent() == true . *///from w w w . j av a 2 s. c o m private void addTitleRowWithSeparator(Context context, float layoutWeightSum, float titleViewWeight) { final TableRow tableNameRow = new TableRow(context); tableNameRow.setId(ElementsIdProvider.getNextId()); tableNameRow.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); tableNameRow.setWeightSum(1f); titleView = Optional .of(getCenteredRowText(context, tableName.get(), layoutWeightSum, true, titleViewWeight)); tableNameRow.addView(titleView.get()); addView(tableNameRow, 1); addView(constructRowSeparator(1), 2); headerOffset += 2; }
From source file:de.tobiasbielefeld.solitaire.ui.manual.ManualGames.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_manual_games, container, false); ((Manual) getActivity()).setGamePageShown(false); layout1 = (ScrollView) view.findViewById(R.id.manual_games_layout_selection); scrollView = (ScrollView) view.findViewById(R.id.manual_games_scrollView); textName = (TextView) view.findViewById(R.id.manual_games_name); textStructure = (TextView) view.findViewById(R.id.manual_games_structure); textObjective = (TextView) view.findViewById(R.id.manual_games_objective); textRules = (TextView) view.findViewById(R.id.manual_games_rules); textScoring = (TextView) view.findViewById(R.id.manual_games_scoring); textBonus = (TextView) view.findViewById(R.id.manual_games_bonus); layout1.setVisibility(View.VISIBLE); scrollView.setVisibility(View.GONE); //if the manual is called from the in game menu, show the corresponding game rule page if (getArguments() != null && getArguments().containsKey(GAME)) { loadGameText(getArguments().getString(GAME)); }/*from ww w . j a v a 2s. com*/ //load the table String[] gameList = lg.getDefaultGameNameList(getResources()); TableRow row = new TableRow(getContext()); TableLayout tableLayout = (TableLayout) view.findViewById(R.id.manual_games_container); TypedValue typedValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, typedValue, true); TableRow.LayoutParams params = new TableRow.LayoutParams(0, TableRow.LayoutParams.WRAP_CONTENT); params.weight = 1; //add each button for (int i = 0; i < lg.getGameCount(); i++) { Button entry = new Button(getContext()); if (i % COLUMNS == 0) { row = new TableRow(getContext()); tableLayout.addView(row); } entry.setBackgroundResource(typedValue.resourceId); entry.setEllipsize(TextUtils.TruncateAt.END); entry.setMaxLines(1); entry.setLayoutParams(params); entry.setText(gameList[i]); entry.setOnClickListener(this); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { entry.setAllCaps(false); } row.addView(entry); } //add some dummies to the last row, if necessary while (row.getChildCount() < COLUMNS) { FrameLayout dummy = new FrameLayout(getContext()); dummy.setLayoutParams(params); row.addView(dummy); } return view; }
From source file:com.github.vseguip.sweet.contacts.SweetConflictResolveActivity.java
/** * @param fieldTable// www . j a v a 2 s. co m * @param nameOfField * @param field */ private void addConflictRow(TableLayout fieldTable, final String nameOfField, final String fieldLocal, final String fieldRemote) { if (mCurrentLocal == null || mCurrentSugar == null) return; // String fieldLocal = mCurrentLocal.get(nameOfField); // String fieldRemote = mCurrentSugar.get(nameOfField); TableRow row = new TableRow(this); final Spinner sourceSelect = new Spinner(this); sourceSelect.setBackgroundResource(R.drawable.black_underline); ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, this.getResources().getStringArray(R.array.conflict_sources)); spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); sourceSelect.setAdapter(spinnerArrayAdapter); // Open the spinner when pressing any of the text fields OnClickListener spinnerOpener = new OnClickListener() { @Override public void onClick(View v) { sourceSelect.performClick(); } }; row.addView(sourceSelect); fieldTable.addView(row); row = new TableRow(this); TextView fieldName = new TextView(this); int stringId = this.getResources().getIdentifier(nameOfField, "string", this.getPackageName()); fieldName.setText(this.getString(stringId)); fieldName.setTextSize(16); fieldName.setPadding(fieldName.getPaddingLeft(), fieldName.getPaddingTop(), fieldName.getPaddingRight() + 10, fieldName.getPaddingBottom()); fieldName.setOnClickListener(spinnerOpener); row.addView(fieldName); final TextView fieldValueLocal = new TextView(this); fieldValueLocal.setText(fieldLocal); fieldValueLocal.setTextSize(16); row.addView(fieldValueLocal); fieldValueLocal.setOnClickListener(spinnerOpener); fieldTable.addView(row); row = new TableRow(this); row.addView(new TextView(this));// add dummy control final TextView fieldValueRemote = new TextView(this); fieldValueRemote.setText(fieldRemote); fieldValueRemote.setTextSize(16); fieldValueRemote.setOnClickListener(spinnerOpener); row.addView(fieldValueRemote); sourceSelect.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (position == 0) { fieldValueLocal.setTextAppearance(SweetConflictResolveActivity.this, R.style.textSelected); fieldValueRemote.setTextAppearance(SweetConflictResolveActivity.this, R.style.textUnselected); resolvedContacts[mPosResolved].set(nameOfField, fieldLocal); } else { fieldValueLocal.setTextAppearance(SweetConflictResolveActivity.this, R.style.textUnselected); fieldValueRemote.setTextAppearance(SweetConflictResolveActivity.this, R.style.textSelected); resolvedContacts[mPosResolved].set(nameOfField, fieldRemote); } } @Override public void onNothingSelected(AdapterView<?> view) { } }); row.setPadding(row.getLeft(), row.getTop() + 5, row.getRight(), row.getBottom() + 10); // Restore appropiate selections according to resolved contact if (resolvedContacts[mPosResolved].get(nameOfField).equals(fieldLocal)) { sourceSelect.setSelection(0); } else { sourceSelect.setSelection(1); } fieldTable.addView(row); }
From source file:com.jdom.word.playdough.android.GamePackPlayerActivity.java
public void updateSourceLetters(List<ButtonConfiguration> buttons) { TableLayout availableLettersTable = (TableLayout) findViewById(R.id.source_letters_table); availableLettersTable.removeAllViews(); TableRow row = new TableRow(this); for (int i = 0; i < buttons.size(); i++) { final ButtonConfiguration buttonConfiguration = buttons.get(i); final String displayText = buttonConfiguration.getDisplayText(); final boolean shouldBeEnabled = buttonConfiguration.isEnabled(); final Runnable clickAction = buttonConfiguration.getClickAction(); if (i == 9 || i == 18) { availableLettersTable.addView(row); row = new TableRow(this); }//from ww w.j a va 2 s.c om final Button button = new Button(this); button.setText(displayText); button.setClickable(shouldBeEnabled); button.setEnabled(shouldBeEnabled); button.setBackgroundColor(Color.BLACK); button.setTextSize(20); int color = (shouldBeEnabled) ? Color.WHITE : Color.BLACK; button.setTextColor(color); if (clickAction != null) { button.setOnClickListener(new OnClickListener() { public void onClick(View v) { clickAction.run(); } }); } row.addView(button); } availableLettersTable.addView(row); }
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 w w.j a v a 2s. 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); } }