List of usage examples for android.widget TableLayout addView
@Override public void addView(View child)
From source file:ch.scythe.hsr.DayFragment.java
private void showInfoRow(TableLayout timeTable, String message) { View descriptionRow = (View) layoutInflater.inflate(R.layout.timetable_info_row, null); TextView infoField = (TextView) descriptionRow.findViewById(R.id.infoRow); infoField.setText(message);// w w w . ja v a 2 s .c om timeTable.addView(descriptionRow); }
From source file:ch.scythe.hsr.DayFragment.java
private void createAndFormatTableRows(List<UiLesson> lessons, TableLayout timeTable, LayoutInflater layoutInflater) { String lastLessonTimeslot = ""; boolean firstRow = true; for (UiLesson lesson : lessons) { View row = layoutInflater.inflate(R.layout.timetable_row, null); timeTable.addView(row); View horizontalLine = row.findViewById(R.id.horizontalLine); if (firstRow) { horizontalLine.setVisibility(View.GONE); firstRow = false;//from www.j ava 2s.c om } TextView timeUnitField = (TextView) row.findViewById(R.id.rowTimeunit); TextView lessonField = (TextView) row.findViewById(R.id.rowLesson); TextView lecturerFieldShort = (TextView) row.findViewById(R.id.rowLecturerShort); TextView lecturerFieldLong = (TextView) row.findViewById(R.id.rowLecturerLong); TextView roomField = (TextView) row.findViewById(R.id.rowRoom); TextView descriptionField = (TextView) row.findViewById(R.id.rowDescription); TextView typeField = (TextView) row.findViewById(R.id.rowType); // fill values into row String newTimeslot = lesson.getTimeSlot(); if (!lastLessonTimeslot.equals(newTimeslot)) { timeUnitField.setText(newTimeslot); } else { timeUnitField.setText(""); horizontalLine.setVisibility(View.GONE); } lastLessonTimeslot = newTimeslot; lessonField.setText(lesson.getName()); roomField.setText(lesson.getRoom()); if (lecturerFieldShort != null) lecturerFieldShort.setText(lesson.getLecturerShort()); if (lecturerFieldLong != null) lecturerFieldLong.setText(lesson.getLecturerLong()); typeField.setText(lesson.getType()); if (lesson.hasDescription()) { descriptionField.setText(lesson.getDescription()); } else { descriptionField.setVisibility(View.GONE); } } }
From source file:org.ementasua.SwipeyTabFragment.java
private void buildDetails(final LayoutInflater inflater, TableLayout tl, final Canteen cant) { final TableLayout body = (TableLayout) inflater.inflate(R.layout.table_menu_title, null); final TableLayout body_list = (TableLayout) body.findViewById(R.id.menu_title_list); tl.addView(body); final Button btL = (Button) body.findViewById(R.id.bt_title_lunch); final Button btD = (Button) body.findViewById(R.id.bt_title_dinner); TextView tvDate = (TextView) body.findViewById(R.id.tv_title_date); final ImageView ib = (ImageView) body.findViewById(R.id.img_share); tvDate.setText(cant.getMicroDate()); tvDate.setGravity(Gravity.RIGHT);// w ww.j a v a 2 s. com if (show_next_day) { Calendar c = Calendar.getInstance(); int hour = c.get(Calendar.HOUR_OF_DAY); if (hour >= 0 && hour < 16) { buildList(inflater, body_list, cant.lunch, false, btL, btD, ib); } else { buildList(inflater, body_list, cant.dinner, true, btL, btD, ib); } show_next_day = false; } else { buildList(inflater, body_list, cant.lunch, false, btL, btD, ib); } btL.setOnClickListener(new OnClickListener() { public void onClick(View v) { buildList(inflater, body_list, cant.lunch, false, btL, btD, ib); } }); btD.setOnClickListener(new OnClickListener() { public void onClick(View v) { buildList(inflater, body_list, cant.dinner, true, btL, btD, ib); } }); }
From source file:com.photocitygame.android.ImageActivity.java
private void addScoreRow(TableLayout scoreTable, String team, int score) { TableRow row = new TableRow(this); TextView tv = new TextView(this); tv.setText(team);/*from ww w .ja va2s. c o m*/ row.addView(tv); TextView scoreView = new TextView(this); scoreView.setText(Integer.toString(score)); scoreView.setGravity(Gravity.RIGHT); row.addView(scoreView); scoreTable.addView(row); }
From source file:com.bonsai.btcreceive.AccountFragment.java
private void addAddressHeader(TableLayout table) { TableRow row = (TableRow) LayoutInflater.from(getActivity()).inflate(R.layout.address_table_header, table, false);//w ww . j a v a 2 s . c o m TextView tv = (TextView) row.findViewById(R.id.header_btc); tv.setText(BaseWalletActivity.getBTCFmt().unitStr()); table.addView(row); }
From source file:de.grobox.liberario.TripsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_trips); getActionBar().setDisplayHomeAsUpEnabled(true); final TableLayout main = (TableLayout) findViewById(R.id.activity_trips); // add horizontal divider at top main.addView(LiberarioUtils.getDivider(this)); Intent intent = getIntent();//from w w w. ja v a 2s. c o m trips = (QueryTripsResult) intent.getSerializableExtra("de.schildbach.pte.dto.QueryTripsResult"); // also get locations, because the trip locations are sometimes still ambiguous from = (Location) intent.getSerializableExtra("de.schildbach.pte.dto.Trip.from"); to = (Location) intent.getSerializableExtra("de.schildbach.pte.dto.Trip.to"); setHeader(); addTrips(main, trips.trips); }
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();//w w w . j av a2 s .c o m if (tiles != null) { tiles.clear(); } } 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.money.manager.ex.home.DashboardFragment.java
private View showTableLayoutTopPayees(Cursor cursor) { LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.dashboard_summary_layout, null); CurrencyService currencyService = new CurrencyService(getActivity().getApplicationContext()); // Textview Title TextView title = (TextView) layout.findViewById(R.id.textViewTitle); title.setText(R.string.top_payees_last_30_days); // Table//from w w w. j a v a 2s.c o m TableLayout tableLayout = (TableLayout) layout.findViewById(R.id.tableLayoutSummary); // Create Title tableLayout.addView(createTableRow( new String[] { "<small><b>" + getString(R.string.payee) + "</b></small>", "<small><b>" + getString(R.string.quantity) + "</b></small>", "<small><b>" + getString(R.string.summary) + "</b></small>" }, new Float[] { 1f, null, null }, new Integer[] { null, Gravity.RIGHT, Gravity.RIGHT }, new Integer[][] { null, { 0, 0, padding_in_px, 0 }, null })); // add rows while (cursor.moveToNext()) { // load values String payee = cursor.getString(cursor.getColumnIndex(ViewMobileData.PAYEE)); double total = cursor.getDouble(cursor.getColumnIndex("TOTAL")); int num = cursor.getInt(cursor.getColumnIndex("NUM")); // Add Row tableLayout.addView(createTableRow( new String[] { "<small>" + payee + "</small>", "<small><i>" + Integer.toString(num) + "</i></small>", "<small>" + currencyService.getCurrencyFormatted(currencyService.getBaseCurrencyId(), MoneyFactory.fromDouble(total)) + "</small>" }, new Float[] { 1f, null, null }, new Integer[] { null, Gravity.RIGHT, Gravity.RIGHT }, new Integer[][] { null, { 0, 0, padding_in_px, 0 }, null })); } // return Layout return layout; }
From source file:com.money.manager.ex.home.DashboardFragment.java
private View showTableLayoutTopWithdrawals(Cursor cursor) { LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.dashboard_summary_layout, null); CurrencyService currencyService = new CurrencyService(getActivity().getApplicationContext()); // Textview Title TextView title = (TextView) layout.findViewById(R.id.textViewTitle); title.setText(R.string.top_withdrawals_last_30_days); // Table/*from w w w .ja v a 2s . c om*/ TableLayout tableLayout = (TableLayout) layout.findViewById(R.id.tableLayoutSummary); // Create Title tableLayout.addView(createTableRow( new String[] { "<small><b>" + getString(R.string.category) + "</b></small>", "<small><b>" + getString(R.string.quantity) + "</b></small>", "<small><b>" + getString(R.string.summary) + "</b></small>" }, new Float[] { 1f, null, null }, new Integer[] { null, Gravity.RIGHT, Gravity.RIGHT }, new Integer[][] { null, { 0, 0, padding_in_px, 0 }, null })); // add rows while (cursor.moveToNext()) { // load values String category = "<b>" + cursor.getString(cursor.getColumnIndex(ViewMobileData.Category)) + "</b>"; if (!TextUtils.isEmpty(cursor.getString(cursor.getColumnIndex(ViewMobileData.Subcategory)))) { category += " : " + cursor.getString(cursor.getColumnIndex(ViewMobileData.Subcategory)); } double total = cursor.getDouble(cursor.getColumnIndex("TOTAL")); int num = cursor.getInt(cursor.getColumnIndex("NUM")); // Add Row tableLayout.addView(createTableRow( new String[] { "<small>" + category + "</small>", "<small><i>" + Integer.toString(num) + "</i></small>", "<small>" + currencyService.getCurrencyFormatted(currencyService.getBaseCurrencyId(), MoneyFactory.fromDouble(total)) + "</small>" }, new Float[] { 1f, null, null }, new Integer[] { null, Gravity.RIGHT, Gravity.RIGHT }, new Integer[][] { null, { 0, 0, padding_in_px, 0 }, null })); } // return Layout return layout; }
From source file:com.keysolutions.meteorparties.PartyDetailFragment.java
/** * Displays party info//from w ww . j a va2s .c o m * @param savedInstanceState instance state * @param rootView view the party display elements are in */ public void showPartyInfo(Bundle savedInstanceState, View rootView) { ((TextView) rootView.findViewById(R.id.party_title)).setText(mParty.getTitle()); ((TextView) rootView.findViewById(R.id.party_description)).setText(mParty.getDescription()); // get ready to show my RSVP info String myUserId = MyDDPState.getInstance().getUserId(); // add RSVP list // NOTE: if you have a lot of RSVPs, you should be using a ListView // The TableLayout is used here to make it this demo simple to // understand if (mParty.getRsvps() != null) { TableLayout table = (TableLayout) rootView.findViewById(R.id.rsvp_list); table.removeAllViews(); // add header TableRow tr = (TableRow) getLayoutInflater(savedInstanceState).inflate(R.layout.header_party_rsvp, null); table.addView(tr); for (Map<String, String> rsvp : mParty.getRsvps()) { String rsvpValue = rsvp.get("rsvp"); String rsvpUser = rsvp.get("user"); if ((myUserId == null) || (!myUserId.equals(rsvpUser))) { // don't add row for my RSVP because that's displayed later tr = (TableRow) getLayoutInflater(savedInstanceState).inflate(R.layout.row_party_rsvp, null); TextView tv; tv = (TextView) tr.findViewById(R.id.user); String email = MyDDPState.getInstance().getUserEmail(rsvpUser); tv.setText(email); tv = (TextView) tr.findViewById(R.id.rsvp); String rsvpDisplayed = ""; int rsvpColor = 0; if (rsvpValue.equals("yes")) { rsvpDisplayed = "Going"; rsvpColor = 0xFF00FF00; } else if (rsvpValue.equals("no")) { rsvpDisplayed = "Declined"; rsvpColor = 0xFFFF0000; } else if (rsvpValue.equals("maybe")) { rsvpDisplayed = "Maybe"; rsvpColor = 0xFF0000FF; } tv.setText(rsvpDisplayed); tv.setTextColor(rsvpColor); table.addView(tr); } } } }