Example #1
0
        @Override
        public void onClick(View arg0) {
          TableRow parentTableRow = (TableRow) arg0.getParent();
          TableLayout parentTableLayout = (TableLayout) parentTableRow.getParent();
          int index = parentTableLayout.indexOfChild(parentTableRow);

          // Getting The String of the removed

          TextView parentTextView = (TextView) parentTableRow.getChildAt(0);
          String parentString = parentTextView.getText().toString();

          parentTableLayout.removeViewAt(index);

          if (parentTableLayout == adSearchMustTableLayout) {
            mustTermsCount--;
            mustTerms.remove(parentString);
            if (mustTermsCount == 0) {
              adSearchMustTableLayout.removeViewAt(0);
              mustTermsPresent = false;
            }
          }
          if (parentTableLayout == adSearchNotTableLayout) {
            notTermsCount--;
            notTerms.remove(parentString);
            if (notTermsCount == 0) {
              adSearchNotTableLayout.removeViewAt(0);
              notTermsPresent = false;
            }
          }
          if (parentTableLayout == adSearchWebsiteTebleLayout) {
            adSearchWebsiteTebleLayout.removeAllViews();
            websitePresent = false;
            websiteToSearch = "";
          }
        }
Example #2
0
  private void addTableRow(String key, String val) {
    TableLayout tl = (TableLayout) findViewById(R.id.data_table);
    TableRow tr = new TableRow(this);
    MarginLayoutParams params =
        new MarginLayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    params.setMargins(TABLE_ROW_MARGIN, TABLE_ROW_MARGIN, TABLE_ROW_MARGIN, TABLE_ROW_MARGIN);
    tr.setLayoutParams(params);
    tr.setBackgroundColor(Color.BLACK);
    TextView name = new TextView(this);
    name.setGravity(Gravity.RIGHT);
    name.setText(key + ": ");
    TextView value = new TextView(this);
    value.setGravity(Gravity.LEFT);
    value.setText(val);
    tr.addView(name);
    tr.addView(value);
    tl.addView(
        tr, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    /*
     * TODO remove this hack
     *
     * let's define a limit number of rows
     */
    if (tl.getChildCount() > 10) tl.removeViewAt(0);
  }
Example #3
0
  private void deleteScheduleAtIndex(int index, String keyToRemove) {
    musicTableScrollView.removeViewAt(index);

    SharedPreferences.Editor editor = musicSearchesEntered.edit();
    editor.remove(keyToRemove);
    editor.apply();
  }
Example #4
0
  /** updates the table from the database. */
  private void updateTable() {
    // delete all but the first row.  remember that the count
    // starts at one and the index starts at zero
    while (dataTable.getChildCount() > 1) {
      // while there are at least two rows in the table widget, delete
      // the second row.
      dataTable.removeViewAt(1);
    }

    // collect the current row information from the database and
    // store it in a two dimensional ArrayList
    //    	ArrayList<ArrayList<Object>> data = db.getAllRowsAsArrays();

    // iterate the ArrayList, create new rows each time and add them
    // to the table widget.

    //		holder.CountsTv.setText(String.valueOf(arg0+1));
    //
    //		holder.ExcerciseName.setText(SiteList.Exc_Name.get(arg0));
    //
    //		holder.DateTv.setText(outputDateStr);
    //
    //		holder.Repetition.setText(SiteList.Log_reps.get(arg0)+" Reps");

    for (int position = 0; position < Log_Date.size(); position++) {

      try {
        date = fromUser.parse(Log_Date.get(position));
      } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      String outputDateStr = myFormat.format(date);
      TableRow tableRow = new TableRow(this);

      //    		ArrayList<Object> row = data.get(position);

      TextView idText = new TextView(this);
      idText.setText(String.valueOf(position + 1));
      //    		idText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
      idText.setWidth((Math.round(display.getWidth() / 6)));
      idText.setPadding(5, 5, 5, 0);
      tableRow.addView(idText);

      TextView textOne = new TextView(this);
      textOne.setText(Exc_Namel.get(position));
      textOne.setWidth((display.getWidth() / 4));
      //    		textOne.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
      textOne.setPadding(3, 5, 5, 0);
      tableRow.addView(textOne);

      TextView textTwo = new TextView(this);
      textTwo.setText(outputDateStr);
      textTwo.setWidth((display.getWidth() / 4));
      //    		textTwo.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
      textTwo.setPadding(3, 5, 5, 0);
      tableRow.addView(textTwo);

      TextView textThree = new TextView(this);
      //    		textThree.set
      textThree.setText(Log_reps.get(position) + " Reps");
      //    		textThree.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
      textThree.setWidth((display.getWidth() / 6));
      textThree.setPadding(3, 5, 5, 3);
      tableRow.addView(textThree);

      dataTable.addView(tableRow);
    }
  }
 /**
  * Removes all items from a table layout on screen
  *
  * @param tableLayout Table that is to be cleared
  */
 private static void clearTable(TableLayout tableLayout) {
   while (tableLayout.getChildCount() > 1) {
     tableLayout.removeViewAt(1);
   }
 }
  private void createEditor() {
    // Assume at least one defined level (two values)
    TableLayout table = (TableLayout) findViewById(R.id.ll_table_config);

    // Clear all
    while (table.getChildCount() > 1) {
      table.removeViewAt(table.getChildCount() - 1);
    }

    TableRow row;

    // First row
    row = createRow();

    // Lower
    row.addView(createTextView(0, "0"));

    // Upper
    row.addView(createTextView(1000, String.valueOf(mLevels[0] - 1)));

    // Screen
    row.addView(createButton(3000, String.valueOf(mLcdValues[0])));

    // Buttons
    row.addView(createButton(4000, String.valueOf(mBtnValues[0])));

    // Keyboard
    if (mHasKeyboard) {
      row.addView(createButton(5000, String.valueOf(mKbValues[0])));
    }

    table.addView(row, table.getChildCount());

    for (int i = 0; i < mLevels.length - 1; i++) {
      row = createRow();

      // Lower
      row.addView(createButton(2000 + i, String.valueOf(mLevels[i])));

      // Upper
      row.addView(createTextView(1000 + i + 1, String.valueOf(Math.max(0, mLevels[i + 1] - 1))));

      // Screen
      row.addView(createButton(3000 + i + 1, String.valueOf(mLcdValues[i + 1])));

      // Buttons
      row.addView(createButton(4000 + i + 1, String.valueOf(mBtnValues[i + 1])));

      // Keyboard
      if (mHasKeyboard) {
        row.addView(createButton(5000 + i + 1, String.valueOf(mKbValues[i + 1])));
      }

      table.addView(row, table.getChildCount());
    }

    row = createRow();

    // Lower
    row.addView(
        createButton(2000 + mLevels.length - 1, String.valueOf(mLevels[mLevels.length - 1])));

    // Upper
    row.addView(createTextView((int) 1e10, String.valueOf((char) '\u221e')));

    // Screen
    row.addView(createButton(3000 + mLevels.length, String.valueOf(mLcdValues[mLevels.length])));

    // Buttons
    row.addView(createButton(4000 + mLevels.length, String.valueOf(mBtnValues[mLevels.length])));

    // Keyboard
    if (mHasKeyboard) {
      row.addView(createButton(5000 + mLevels.length, String.valueOf(mKbValues[mLevels.length])));
    }

    table.addView(row, table.getChildCount());

    table.setColumnStretchable(0, true);
    table.setColumnStretchable(2, true);
    table.setColumnStretchable(3, true);
    if (mHasKeyboard) {
      table.setColumnStretchable(4, true);
    }
  }