List of usage examples for android.widget TableLayout removeAllViews
public void removeAllViews()
From source file:com.svpino.longhorn.artifacts.StockTileProcessor.java
public static void create(Fragment fragment, TableLayout tableLayout, List<Stock> stocks, SparseArray<View> tiles, boolean restart) { if (restart) { tableLayout.removeAllViews(); if (tiles != null) { tiles.clear();// ww w . j a v a 2 s. co m } } tableLayout.setStretchAllColumns(true); tableLayout.setShrinkAllColumns(true); int margin = Extensions.dpToPixels(fragment.getResources(), 3); int height = Extensions.dpToPixels(fragment.getResources(), 90); int index = createFixedHeaderRow(fragment, tableLayout, stocks, tiles, height, margin); int row = index == 3 ? 1 : 0; while (index < stocks.size()) { index = createStandardRow(fragment, tableLayout, stocks, tiles, height, margin, index, row); row++; } while (tableLayout.getChildCount() > row) { tableLayout.removeViewAt(tableLayout.getChildCount() - 1); } if (stocks.size() % 2 != 0) { TableRow tableRow = new TableRow(fragment.getActivity()); View addNewStockTile = createTileForAddingNewStock(fragment); tableRow.addView(addNewStockTile, getSpannedLayoutParams(row, margin, height)); tableLayout.addView(tableRow); } else { TableRow tableRow = (TableRow) tableLayout.getChildAt(tableLayout.getChildCount() - 1); LayoutParams layoutParams = (TableRow.LayoutParams) tableRow.getChildAt(0).getLayoutParams(); layoutParams.bottomMargin = margin; layoutParams.height = height; } }
From source file:com.jeffreyawest.weblogic.monitor.charting.DefaultPieChart.java
protected final void updateLegend(final String[] pNAME_list, final Integer[] pCOLORS, int pID) { TableLayout tl = (TableLayout) getActivity().findViewById(pID); if (tl != null) { tl.removeAllViews(); for (int x = 0; x < pNAME_list.length; x++) { tl.addView(getRow(getActivity(), pCOLORS[x], pNAME_list[x])); }/*from ww w.j av a 2 s . com*/ } }
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); }// ww w . j a v a2 s. c o m 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:at.ac.uniklu.mobile.sportal.DashboardUpcomingDatesFragment.java
private void populateUpcomingDates() { long startTime = System.currentTimeMillis(); TableLayout dateListTable = (TableLayout) getView().findViewById(R.id.dates); dateListTable.removeAllViews(); if (mDashboardModel.getDates().isEmpty()) { getView().findViewById(R.id.dates_empty).setVisibility(View.VISIBLE); return;//from w w w . j av a 2 s. c o m } 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:org.ementasua.SwipeyTabFragment.java
@Override public void onResume() { super.onResume(); TableLayout v = (TableLayout) getView().findViewById(R.id.tableLayout); v.removeAllViews(); for (Canteen cant : getCanteens()) buildDetails(inflat, v, cant);//from w w w. j a v a2 s. co m }
From source file:ch.scythe.hsr.DayFragment.java
public void updateDate(UiWeek week) { this.week = week; View view = getView();//w ww .ja va 2 s . c om if (view != null) { TableLayout timeTable = (TableLayout) view.findViewById(R.id.timeTable); // remove all existing table rows and add them again timeTable.removeAllViews(); updateTable(timeTable); } else { Log.w("DayFragment", "Not possible to update data as the view is not available."); } }
From source file:mx.udlap.is522.tedroid.activity.ScoresActivity.java
/** * Setea los valores de los objetos Score proporcionados o manda un mensaje si no hay datos. * /*from ww w . j a v a 2 s.c om*/ * @param scores objetos Score. */ private void setUpScores(List<Score> scores, TableLayout table) { if (scores != null && !scores.isEmpty()) { table.removeAllViews(); table.addView(createHeaderRow()); for (Score score : scores) table.addView(toTableRow(score)); } else { table.removeAllViews(); table.addView(emptyScoresRow()); } }
From source file:com.sim2dial.dialer.ContactFragment.java
private void displayContact(LayoutInflater inflater, View view) { AvatarWithShadow contactPicture = (AvatarWithShadow) view.findViewById(R.id.contactPicture); if (contact.getPhotoUri() != null) { InputStream input = Compatibility.getContactPictureInputStream( LinphoneActivity.instance().getContentResolver(), contact.getID()); contactPicture.setImageBitmap(BitmapFactory.decodeStream(input)); } else {//from ww w .ja v a 2 s . c o m contactPicture.setImageResource(R.drawable.unknown_small); } TextView contactName = (TextView) view.findViewById(R.id.contactName); contactName.setText(contact.getName()); TableLayout controls = (TableLayout) view.findViewById(R.id.controls); controls.removeAllViews(); for (String numberOrAddress : contact.getNumerosOrAddresses()) { View v = inflater.inflate(R.layout.contact_control_row, null); String displayednumberOrAddress = numberOrAddress; if (numberOrAddress.startsWith("sip:")) { displayednumberOrAddress = displayednumberOrAddress.substring(4); } TextView tv = (TextView) v.findViewById(R.id.numeroOrAddress); tv.setText(displayednumberOrAddress); tv.setSelected(true); if (!displayChatAddressOnly) { v.findViewById(R.id.dial).setOnClickListener(dialListener); v.findViewById(R.id.dial).setTag(displayednumberOrAddress); } else { v.findViewById(R.id.dial).setVisibility(View.GONE); } v.findViewById(R.id.chat).setOnClickListener(chatListener); if (LinphoneUtils.isSipAddress(numberOrAddress)) { v.findViewById(R.id.chat).setTag(numberOrAddress); } else { LinphoneProxyConfig lpc = LinphoneManager.getLc().getDefaultProxyConfig(); if (lpc != null) { if (!numberOrAddress.startsWith("sip:")) { numberOrAddress = "sip:" + numberOrAddress; } v.findViewById(R.id.chat).setTag(numberOrAddress + "@" + lpc.getDomain()); } } final String finalNumberOrAddress = numberOrAddress; ImageView friend = (ImageView) v.findViewById(R.id.addFriend); if (getResources().getBoolean(R.bool.enable_linphone_friends) && !displayChatAddressOnly) { friend.setVisibility(View.VISIBLE); boolean isAlreadyAFriend = LinphoneManager.getLc() .findFriendByAddress(finalNumberOrAddress) != null; if (!isAlreadyAFriend) { friend.setImageResource(R.drawable.friend_add); friend.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (LinphoneActivity.instance().newFriend(contact, finalNumberOrAddress)) { displayContact(ContactFragment.this.inflater, ContactFragment.this.view); } } }); } else { friend.setImageResource(R.drawable.friend_remove); friend.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (LinphoneActivity.instance().removeFriend(contact, finalNumberOrAddress)) { displayContact(ContactFragment.this.inflater, ContactFragment.this.view); } } }); } } if (getResources().getBoolean(R.bool.disable_chat)) { v.findViewById(R.id.chat).setVisibility(View.GONE); } controls.addView(v); } }
From source file:nl.openkvk.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TableLayout tl = (TableLayout) findViewById(R.id.tableOuter); tl.removeAllViews(); }
From source file:nl.openkvk.MainActivity.java
public void clearFields(View view) { ((EditText) findViewById(R.id.inpNaam)).setText(""); ((EditText) findViewById(R.id.inpStraat)).setText(""); ((EditText) findViewById(R.id.inpPostcode)).setText(""); ((EditText) findViewById(R.id.inpPlaats)).setText(""); TableLayout tl = (TableLayout) findViewById(R.id.tableOuter); tl.removeAllViews(); }