예제 #1
0
  /**
   * -=========================================/ generateOutput() -- Fill R.id.numberBox with bases
   * and squares and cubes. Note that this method simply assumes that start >= end. This should
   * always be the case, as setLimits() does this error checking.
   * /==========================================-
   */
  private void generateOutput(int start, int end) {
    ViewGroup.LayoutParams widthHeightSettings =
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    // I will later pass this object to TableRows (as they are created) to define their width and
    // height.
    TableLayout numberContainer = (TableLayout) findViewById(R.id.numberBox);
    numberContainer.removeAllViews();
    int row, column;
    Context appContext = getApplicationContext();

    for (row = 0; row <= (end - start); row++) {
      // Create a TableRow row.
      TableRow aRow = new TableRow(appContext);
      aRow.setId(row);
      aRow.setLayoutParams(widthHeightSettings);
      numberContainer.addView(aRow);

      for (column = 0; column < 3; column++) {
        // Create a TextView column, and place it in the just-created TableRow row.
        TextView aNumber = new TextView(appContext);
        // aNumber.setLayoutParams(widthHeightSettings);
        // Fails. I don't know why.
        aNumber.setText(Double.toString(Math.pow(start + row, 1 + column)));
        ((TableRow) numberContainer.findViewById(row)).addView(aNumber);
      }
    }
  }
예제 #2
0
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.btnAddPeople:
        final TableRow tr = new TableRow(this);
        tr.setId(1);

        EditText editText = new EditText(this);
        editText.setId(200);
        editText.setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
        editText.setMinWidth(100);
        //			labelTV.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
        // LayoutParams.WRAP_CONTENT));

        tr.addView(editText);
        editText.requestFocus();

        Button deleteButton = new Button(this);
        deleteButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.delete));
        deleteButton.setId(200);
        deleteButton.setOnClickListener(
            new OnClickListener() {
              public void onClick(View v) {
                tblPersons.removeView(tr);
              }
            });

        tr.addView(deleteButton);

        tblPersons.addView(tr);

        break;
      case R.id.btnContinue:
        String names = "";

        for (int i = 0; i < tblPersons.getChildCount(); i++) {
          TableRow row = (TableRow) tblPersons.getChildAt(i);
          String name = ((EditText) (row.getChildAt(0))).getText().toString();
          if (name != null && name.trim() != "") {
            names = names + name.trim();
          }

          if (i < tblPersons.getChildCount() - 1) {
            names = names + ",";
          }
        }

        System.out.println("!!!!!!!!!!names:" + names);

        Intent intentExpenses = new Intent();
        intentExpenses.setClassName("com.expenses", "com.expenses.ExpensesShareActivity");
        intentExpenses.putExtra("com.expenses.PersonNames", names);
        startActivity(intentExpenses);

        break;
      default:
        break;
    }
  }
예제 #3
0
  public void loadTable() {
    TableLayout table = (TableLayout) findViewById(R.id.table);
    // table.setColumnStretchable(1, true);
    table.removeAllViews();

    final ArrayList<View> rowList = new ArrayList<View>();

    for (int i = 0; i < balance.size(); i++) {
      // final LoaderImageView image = new LoaderImageView(getContext(), getUsersmallimg());
      final LoaderImageView image =
          new LoaderImageView(
              getContext(),
              balance.get(i).getApp().getImageUrl(),
              (int) (ratio * 60),
              (int) (ratio * 60));

      TableRow row =
          createRow(
              image,
              balance.get(i).getApp().getName(),
              balance.get(i).getCreationdate(),
              balance.get(i).getValue(),
              balance.get(i).getReason(),
              getContext());
      row.setId(i);
      rowList.add(row);
      View spacer = createSpacer(getContext(), 1, 1);
      spacer.setId(-100);
      rowList.add(spacer);
      View spacer2 = createSpacer(getContext(), 2, 1);
      spacer2.setId(-100);
      rowList.add(spacer2);
      BeButton b = new BeButton(current.getContext());
      if (i % 2 == 0)
        row.setBackgroundDrawable(
            b.setPressedBackg(
                new BDrawableGradient(0, (int) (ratio * 70), BDrawableGradient.LIGHT_GRAY_GRADIENT),
                new BDrawableGradient(0, (int) (ratio * 70), BDrawableGradient.HIGH_GRAY_GRADIENT),
                new BDrawableGradient(
                    0, (int) (ratio * 70), BDrawableGradient.HIGH_GRAY_GRADIENT)));
      else
        row.setBackgroundDrawable(
            b.setPressedBackg(
                new BDrawableGradient(0, (int) (ratio * 70), BDrawableGradient.GRAY_GRADIENT),
                new BDrawableGradient(0, (int) (ratio * 70), BDrawableGradient.HIGH_GRAY_GRADIENT),
                new BDrawableGradient(
                    0, (int) (ratio * 70), BDrawableGradient.HIGH_GRAY_GRADIENT)));
    }

    for (View row : rowList) {
      table.addView(row);
    }
  }
예제 #4
0
 private void makeBlock() {
   TableRow row = new TableRow(this);
   row.setLayoutParams(this.rowLP);
   row.setId(this.rowID);
   row.setBackgroundResource(R.drawable.resultcorners);
   this.addListenerOnButton(row);
   this.rowID++;
   ImageView img = new ImageView(this);
   img.setLayoutParams(imgLP);
   img.setImageResource(R.drawable.testcover);
   row.addView(img);
   LinearLayout linLayout = new LinearLayout(this);
   linLayout.setLayoutParams(linLayoutLP);
   linLayout.setOrientation(LinearLayout.VERTICAL);
   TextView title = new TextView(this);
   title.setLayoutParams(textLP);
   title.setTextColor(Integer.parseInt("545455", 16) + 0xFF000000);
   title.setText("Englehaderen");
   linLayout.addView(title);
   TextView author = new TextView(this);
   author.setLayoutParams(textLP);
   author.setTextColor(Integer.parseInt("545455", 16) + 0xFF000000);
   author.setText("by: Lisa Marklund");
   linLayout.addView(author);
   TextView format = new TextView(this);
   format.setLayoutParams(textLP);
   format.setTextColor(Integer.parseInt("545455", 16) + 0xFF000000);
   format.setText("format: E-bog");
   linLayout.addView(format);
   TextView forlag = new TextView(this);
   forlag.setLayoutParams(textLP);
   forlag.setTextColor(Integer.parseInt("545455", 16) + 0xFF000000);
   forlag.setText("publisher: Gyldendal");
   linLayout.addView(forlag);
   TextView year = new TextView(this);
   year.setLayoutParams(textLP);
   year.setTextColor(Integer.parseInt("545455", 16) + 0xFF000000);
   year.setText("year: 2009");
   linLayout.addView(year);
   TextView ISBN = new TextView(this);
   ISBN.setLayoutParams(textLP);
   ISBN.setTextColor(Integer.parseInt("545455", 16) + 0xFF000000);
   ISBN.setText("ISBN: 645-987264-372");
   linLayout.addView(ISBN);
   row.addView(linLayout);
   this.table.addView(row);
 }
  public void getreportsent() {
    int i = 0;

    TableRow tr1 = new TableRow(this);
    tr1.setId(100 + i);
    tr1.layout(2, 0, 0, 0);

    // Create a TextView to house the name of the province
    final TextView label2 = new TextView(this);

    label2.setId(300 + i);
    label2.setText("      ");
    label2.setTextColor(Color.BLACK);
    label2.setPadding(20, 0, 0, 0);
    tr1.setPadding(0, 1, 0, 1);

    tr1.addView(label2);

    // Create a TextView to house the name of the province
    final TextView labeltitle2 = new TextView(this);

    labeltitle2.setId(300 + i);
    labeltitle2.setText("Subject");
    labeltitle2.setTextColor(Color.BLACK);
    labeltitle2.setPadding(20, 0, 0, 0);
    tr1.setPadding(0, 1, 0, 1);

    tr1.addView(labeltitle2);

    /*// Create a TextView to house the name of the province
    final TextView labelsend2 = new TextView(this);


    labelsend2.setId(500+i);
    labelsend2.setText("From");
    labelsend2.setTextColor(Color.BLACK);

    tr1.addView(labelsend2);*/

    // Create a TextView to house the value of the after-tax income
    final TextView labelrec2 = new TextView(this);

    labelrec2.setId(400 + i);
    labelrec2.setText("To");
    labelrec2.setTextColor(Color.BLACK);
    labelrec2.setPadding(20, 0, 0, 0);
    tr1.setPadding(0, 1, 0, 1);

    tr1.addView(labelrec2);

    // Create a TextView to house the value of the after-tax income
    final TextView labeldt2 = new TextView(this);

    labeldt2.setId(600 + i);
    labeldt2.setText("Date");
    labeldt2.setTextColor(Color.BLACK);
    labeldt2.setPadding(20, 0, 0, 0);
    tr1.setPadding(0, 1, 0, 1);

    tr1.addView(labeldt2);

    // Add the TableRow to the TableLayout
    tbl3.addView(
        tr1, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

    for (int i1 = 0; i1 < rec2.length; i1++) {

      try {
        TableRow tr = new TableRow(this);
        tr.setId(100 + i);
        tr.layout(2, 0, 0, 0);

        // Create a TextView to house the name of the province
        final CheckBox chk1 = new CheckBox(this);
        ;

        chk1.setId(200 + i);
        chk1.setText("");
        chk1.setPadding(20, 0, 0, 0);
        tr.setPadding(0, 1, 0, 1);

        tr.addView(chk1);

        // Create a TextView to house the name of the province
        final TextView labeltitle1 = new TextView(this);

        labeltitle1.setId(300 + i);
        labeltitle1.setText(title2[i1]);
        labeltitle1.setTextColor(Color.BLACK);
        labeltitle1.setPadding(20, 0, 0, 0);
        tr.setPadding(0, 1, 0, 1);

        tr.addView(labeltitle1);

        /*// Create a TextView to house the name of the province
        final TextView labelsend1 = new TextView(this);


        labelsend1.setId(500+i);
        labelsend1.setText(send2[i1]);
        labelsend1.setTextColor(Color.BLACK);

        tr.addView(labelsend1);*/

        // Create a TextView to house the value of the after-tax income
        final TextView labelrec1 = new TextView(this);

        labelrec1.setId(400 + i);
        labelrec1.setText("" + rec2[i1]);
        labelrec1.setTextColor(Color.BLACK);
        labelrec1.setPadding(20, 0, 0, 0);
        tr.setPadding(0, 1, 0, 1);

        tr.addView(labelrec1);

        int date1 = Integer.parseInt(dt2[i1]);

        Date date = new Date(date1 * 1000L);

        SimpleDateFormat postFormater = new SimpleDateFormat("dd-MM-yyyy");

        String newDateStr = postFormater.format(date);

        // Create a TextView to house the value of the after-tax income
        final TextView labeldt1 = new TextView(this);

        labeldt1.setId(600 + i);
        labeldt1.setText("" + newDateStr);
        labeldt1.setTextColor(Color.BLACK);
        labeldt1.setPadding(20, 0, 0, 0);
        tr.setPadding(0, 1, 0, 1);

        tr.addView(labeldt1);

        final TextView labelbody1 = new TextView(this);

        labelbody1.setId(700 + i);
        labelbody1.setText("" + body2[i1]);
        labelbody1.setTextColor(Color.BLACK);
        labelbody1.setVisibility(View.GONE);

        labelbody1.setPadding(20, 0, 0, 0);
        tr.setPadding(0, 1, 0, 1);

        tr.addView(labelbody1);

        // Add the TableRow to the TableLayout
        tbl3.addView(
            tr, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
        i++;

        labeltitle1.setOnClickListener(
            new TextView.OnClickListener() {

              public void onClick(View v) {

                myDialog1 = new Dialog(mailbox.this);
                myDialog1.setContentView(R.layout.showmail);
                myDialog1.setTitle("Sent Mails");
                myDialog1.setCancelable(true);

                TextView from = (TextView) myDialog1.findViewById(R.id.txtfrom);
                TextView date = (TextView) myDialog1.findViewById(R.id.txtdate);
                TextView to = (TextView) myDialog1.findViewById(R.id.txtto);
                TextView title = (TextView) myDialog1.findViewById(R.id.txttitle);
                EditText body = (EditText) myDialog1.findViewById(R.id.editto);
                Button button = (Button) myDialog1.findViewById(R.id.btnback);

                String rec1 = labelrec1.getText().toString();

                String date1 = labeldt1.getText().toString();

                // String send1=labelsend1.getText().toString();

                String title1 = labeltitle1.getText().toString();

                String body1 = labelbody1.getText().toString();
                button.setText("Back To Sent mails");

                // from.setText(send1);
                date.setText(date1);
                to.setText(rec1);
                title.setText(title1);
                body.setText(body1);

                button.setOnClickListener(
                    new OnClickListener() {
                      public void onClick(View v) {
                        myDialog1.dismiss();
                      }
                    });

                myDialog1.show();
              }
            });
      } catch (Exception e) {
        tv.setText(e.getMessage());
      }
    }
  }
예제 #6
0
  private void fillData() {
    final TableLayout table = (TableLayout) findViewById(R.id.treatments_table);
    TableRow tr;
    TextView tv;
    final Cursor cursor = TreatmentsDbAdapter.getInstance(this).fetchAllCurrent();
    startManagingCursor(cursor);
    cursor.moveToFirst();
    table.removeAllViews();
    addHeadline(table);
    while (cursor.isAfterLast() == false) {
      tr = (TableRow) getLayoutInflater().inflate(R.layout.treatments_row, null);
      tr.setPadding(0, 10, 0, 0);

      // set id
      final int id = cursor.getInt(cursor.getColumnIndex(TreatmentsDbAdapter.KEY_ROWID));
      tr.setId(id);

      // set medicine name cell
      tv = (TextView) tr.findViewById(R.id.treatment_row_medicament_name);
      int medId = cursor.getInt(cursor.getColumnIndex(TreatmentsDbAdapter.KEY_MEDICAMENT_ID));
      Cursor medCur = MedicamentsDbAdapter.getInstance(this).fetchOne(medId);
      if (medCur.getCount() != 1) return;
      String curStr = medCur.getString(medCur.getColumnIndex(MedicamentsDbAdapter.KEY_NAME));
      if (curStr.length() >= 15) {
        curStr = curStr.substring(0, 15);
        curStr += "...";
      }
      tv.setText(curStr);

      // set frequency cell
      tv = (TextView) tr.findViewById(R.id.treatment_row_treatment_frequency);
      int freqId = cursor.getInt(cursor.getColumnIndex(TreatmentsDbAdapter.KEY_FREQUENCY_ID));
      Cursor freqCur = FrequenciesDbAdapter.getInstance(this).fetchOne(freqId);
      if (freqCur.getCount() != 1) return;
      curStr =
          ResourcesServe.getFrequencyName(
              this, freqCur.getString(freqCur.getColumnIndex(FrequenciesDbAdapter.KEY_NAME)));
      // TODO: get string from resources
      if (curStr.length() >= 15) {
        curStr = curStr.substring(0, 15);
        curStr += "...";
      }
      tv.setText(curStr);

      // pills to take
      tv = (TextView) tr.findViewById(R.id.treatment_row_pills_to_take);
      int all = cursor.getInt(cursor.getColumnIndex(TreatmentsDbAdapter.KEY_PILLS));
      int taken = cursor.getInt(cursor.getColumnIndex(TreatmentsDbAdapter.KEY_PILLS_TAKEN));
      tv.setText(Integer.toString(all - taken));

      // set active
      CheckBox cb = (CheckBox) tr.findViewById(R.id.treatment_row_active);
      if (cursor.getInt(cursor.getColumnIndex(TreatmentsDbAdapter.KEY_ACTIVE)) == 0)
        cb.setChecked(false);
      else cb.setChecked(true);
      cb.setOnCheckedChangeListener(
          new OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
              if (isChecked == false) {
                confirmDisactivation(id);
              } else {
                TreatmentsDbAdapter.getInstance(getApplicationContext()).updateActive(true, id);
                AlarmScheduler.scheduleTreatment(
                    getApplicationContext(), id, AlarmScheduler.TYPE_CONFIRMATION);
                TreatmentsDbAdapter.getInstance(getApplicationContext()).updateScheduled(true, id);
                // Toast.makeText(getApplicationContext(), "wybrano: " + id,
                // Toast.LENGTH_SHORT).show();
              }
            }
          });

      table.addView(tr);
      // registerForContextMenu(tr);

      cursor.moveToNext();
    }
  }
  private void GetAnswers(Integer _id) {

    openDatabaseConnection();

    String WhereStatement = "QUESTIONITEM " + "= " + String.valueOf(_id);
    String[] Columns = {"CORRECT", "ANSWERTEXT", "REASON"};

    Cursor c = myDbHelper.query("ANSWERS", Columns, WhereStatement, null, null, null, null);

    if (c.getCount() > 0) {

      c.moveToFirst();

      List<Answer> list = new ArrayList<Answer>();
      CorrectAnswerList = new ArrayList<Answer>();
      CorrectAnswerInHTMLList = new ArrayList<String>();
      do {
        Answer ans = new Answer();
        ans.set_Correct(c.getInt(c.getColumnIndex("CORRECT")));
        ans.set_AnswerText(c.getString(c.getColumnIndex("ANSWERTEXT")));
        ans.set_Reason(c.getString(c.getColumnIndex("REASON")));
        list.add(ans);
        // if the answer is correct keep the string in HTML
        if (ans.get_Correct() == 1) {
          String CorrectAnswerInHTML = ans.get_AnswerText();
          CorrectAnswerReasonInHTML = ans.get_Reason();
          CorrectAnswerList.add(ans); // Collection of correct answers
          CorrectAnswerInHTMLList.add(CorrectAnswerInHTML);
          CorrectAnswerInHTMLListCounter++;
        }
      } while (c.moveToNext());

      c.close();
      myDbHelper.close();

      // Add the number of Answer to the CorrectAnswerListCounter
      CorrectAnswerListCounter = CorrectAnswerList.size();

      // Initialize button array
      ButtonArray = new ArrayList<Button>();

      for (int current = 0; current < list.size(); current++) {
        Answer ThisAns = list.get(current);
        // Create a table row
        TableRow tr = new TableRow(this);
        tr.setId(1000 + current);
        tr.setGravity(Gravity.CENTER);

        tr.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

        /*TextView Tv = new TextView(this);
        Tv.setId(1000+current);
        Tv.setText(Html.fromHtml(ThisAns.get_AnswerText()));
        Tv.setTextColor(Color.WHITE);

           tr.addView(Tv);

           Table.addView(tr);*/

        // Configure each button and add to row and then add row to table
        Button bt = new Button(this);
        bt.setId(1000 + current);
        bt.setText(Html.fromHtml(ThisAns.get_AnswerText()));
        bt.setTextColor(Color.BLACK);
        bt.setGravity(Gravity.CENTER);
        bt.setWidth(420);
        bt.setHeight(LayoutParams.WRAP_CONTENT);
        bt.setTextSize(12);
        // Add the correct answer to the button
        bt.setTag(ThisAns.get_Correct());

        bt.setOnClickListener(this);
        // Add button the button array
        ButtonArray.add(bt);

        tr.addView(bt);

        Table.addView(tr);
      }
    }
  }
예제 #8
0
  private void TabloDoldur() {
    try {

      Integer count = 0;
      YeDatabase db = new YeDatabase(this);
      final ObDataBase yDb = new ObDataBase(this);
      db.open();
      final Cursor cursor = db.QueryTbDataBases();
      tlResults.removeAllViews();
      while (cursor.moveToNext()) {

        yDb.ID = cursor.getInt(0);
        yDb.Name = cursor.getString(1);
        yDb.Instance = cursor.getString(2);
        yDb.Ip = cursor.getString(3);
        yDb.Port = cursor.getString(4);
        yDb.User = cursor.getString(5);
        yDb.Pass = cursor.getString(6);
        yDb.InUse = cursor.getInt(7);
        yDb.Description = cursor.getString(8);

        LayoutInflater inflater =
            (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        TableRow tr = (TableRow) inflater.inflate(R.layout.satir, null);

        tr.setId(100 + count);
        tr.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

        TextView labelDesc = new TextView(this, null, R.style.BodyText);
        labelDesc.setId(200 + count);
        labelDesc.setText(yDb.Description);
        tr.addView(labelDesc);

        TextView labelIp = new TextView(this, null, R.style.BodyText);
        labelIp.setId(200 + count);
        labelIp.setText(yDb.Ip);
        tr.addView(labelIp);

        TextView labelName = new TextView(this);
        labelName.setId(200 + count);
        labelName.setText(yDb.Name);
        tr.addView(labelName);

        RadioButton labelInUse = new RadioButton(this);
        labelInUse.setId(200 + count);
        labelInUse.setTag(200 + "");
        labelInUse.setGravity(Gravity.CENTER_VERTICAL);
        labelInUse.setGravity(Gravity.CENTER_HORIZONTAL);
        labelInUse.setEnabled(false);

        // rdgActiveData.addView(labelInUse);
        if (yDb.InUse == 1) labelInUse.setChecked(true);
        else labelInUse.setChecked(false);

        tr.addView(labelInUse);

        tlResults.addView(
            tr, new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        count++;

        tr.setOnClickListener(
            new OnClickListener() {
              @Override
              public void onClick(View view) {
                DetayDoldur((TableRow) view);
              }
            });
        tr.setOnLongClickListener(
            new OnLongClickListener() {

              @Override
              public boolean onLongClick(View v) {
                SetAktifVeriTabani((TableRow) v);
                return true;
              }
            });
      }
    } catch (Exception e) {
      Toast.makeText(this, "detay göster" + e.getMessage(), Toast.LENGTH_LONG).show();
    }
  }
예제 #9
0
  /**
   * Ajoute une nouvelle TableRow au TableLayout contenant la liste des ports favoris.
   *
   * @param selectedPort le port à ajouter
   */
  public void addTableRow(int selectedPort) {
    TableRow tr = new TableRow(this);
    tr.setId(1000 + selectedPort);
    tr.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    TextView labelPort = new TextView(this);
    labelPort.setId(2000 + selectedPort);
    labelPort.setText(mPortName[selectedPort]);
    // labelPort.setTextColor(Color.RED);
    labelPort.setLayoutParams(
        new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    tr.addView(labelPort);

    // Quand on clique sur le nom du port, on va lancer l'activité qui
    // affiche les marées pour le port en question
    labelPort.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            // On récupère l'ID du port
            int port = v.getId() - 2000;

            // Le Bundle sert à stocker des valeurs que l'on souhaite
            // transmettre à la nouvelle activité. Ici le numéro du port
            // pour pouvoir construire l'URL du widget, et le nom du port
            // pour l'afficher dans la barre de titre (purement cosmétique).
            Bundle bundle = new Bundle();
            bundle.putInt("info.yakablog.hmarees.port", mPortNumber[port]);
            bundle.putString("info.yakablog.hmarees.portName", mPortName[port]);

            // On lance l'activité qui va afficher les horaires de marées.
            Intent myIntent = new Intent(v.getContext(), ViewTides.class);
            myIntent.putExtras(bundle);
            startActivity(myIntent);
          }
        });

    // On crée le bouton "supprimer" et on l'ajoute à la TableRow
    Button supprPort = new Button(this);
    supprPort.setId(3000 + selectedPort);
    supprPort.setText("[-]");
    supprPort.setLayoutParams(
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    supprPort.setGravity(Gravity.RIGHT);
    tr.addView(supprPort);

    // On exécute l'action suivante lorsqu'on clique sur le bouton Supprimer
    supprPort.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            int port = v.getId() - 3000;
            int viewToRemoveIndex = tablePorts.indexOfChild((View) v.getParent());

            // Supprime la TableRow sélectionnée (donc le nom du port et
            // le bouton "supprimer" associé)
            tablePorts.removeViewAt(viewToRemoveIndex);
            // Supprime le séparateur suivant la TableRow qu'on vient de
            // supprimer (ce séparateur a maintenant le même index que la
            // TableRow)
            tablePorts.removeViewAt(viewToRemoveIndex);

            // Maintenant on reconstruit la liste des ports sans celui qui
            // vient d'être supprimé et on écrit cette liste dans les
            // préférences.
            SharedPreferences.Editor editor = prefs.edit();
            String listePorts = prefs.getString("listeports", "");
            String[] arrayListPortsSrc = listePorts.split("#");
            ArrayList<String> arrayListPortsDest = new ArrayList<String>();
            for (String thisPort : arrayListPortsSrc) {
              if (!thisPort.equals("" + port)) {
                arrayListPortsDest.add(thisPort);
              }
            }
            String newPortsList = "";
            for (String newPort : arrayListPortsDest) {
              if (!newPortsList.equals("")) {
                newPortsList += "#";
              }
              newPortsList += newPort;
            }
            editor.putString("listeports", newPortsList);
            editor.commit();
          }
        });

    // On ajoute la TableRow enfin créée à la table des ports favoris
    tablePorts.addView(
        tr, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

    // On ajoute également à la suite de la nouvelle TableRow un séparateur
    View separation = new View(this);
    separation.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 2));
    separation.setBackgroundColor(Color.parseColor("#FF909090"));
    tablePorts.addView(separation);
  }