Esempio n. 1
0
  public void init() {

    TableLayout attendanceTable = (TableLayout) findViewById(R.id.attendanceTableLayout);
    CheckBox checkBox;
    TextView tv;
    ImageButton addBtn;
    for (int i = 0; i < 2; i++) {

      TableRow row = new TableRow(this);
      TableRow.LayoutParams lp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT);
      row.setLayoutParams(lp);
      checkBox = new CheckBox(this);
      tv = new TextView(this);
      addBtn = new ImageButton(this);
      addBtn.setImageResource(R.drawable.student_pic);
      addBtn.setMaxWidth(10);
      addBtn.setMaxHeight(10);
      checkBox.setText("Mark: ");
      tv.setText("Student " + i);
      row.addView(checkBox);
      row.addView(tv);
      row.addView(addBtn);
      attendanceTable.addView(row, i);
    }
  }
  private TableRow createRow(
      RowId rowId,
      String label,
      String defaultValue,
      String btnText,
      View.OnClickListener btnListener) {

    TableRow tb = new TableRow(this);
    TextView labelText = new TextView(this);
    TextView valueText = new TextView(this);
    Button btn = new Button(this);

    labelText.setText(label);
    valueText.setText(defaultValue);
    btn.setText(btnText);

    btn.setOnClickListener(btnListener);

    tb.addView(labelText);
    tb.addView(valueText);
    tb.addView(btn);

    mRowIdButtonMap.put(rowId, btn);
    mRowIdValueTextViewMap.put(rowId, valueText);
    mViewRowIdMap.put(btn, rowId);

    return tb;
  }
Esempio n. 3
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);
  }
  public TableRow createRow(String rowName, String rowValue, int colour) {

    TableRow tableRow = new TableRow(context);
    tableRow.setLayoutParams(
        new TableRow.LayoutParams(
            TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));

    TextView textView = new TextView(context);
    textView.setText(rowName);
    textView.setTextColor(colour);
    textView.setTextSize(20.0f);

    TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(0);
    layoutParams.width = 175;
    textView.setLayoutParams(layoutParams);

    TextView textViewValue = new TextView(context);
    textViewValue.setText(rowValue);
    textViewValue.setTextColor(colour);
    textViewValue.setTextSize(20.0f);
    textViewValue.setGravity(Gravity.RIGHT);
    textViewValue.setLayoutParams(new TableRow.LayoutParams(1));

    tableRow.addView(textView);
    tableRow.addView(textViewValue);

    return tableRow;
  }
Esempio n. 5
0
 protected void initBoard() {
   numericBoardView = new TableLayout(this);
   imageBoardView = new TableLayout(this);
   final Board board = getBoardModel();
   board.addMoveListener(this);
   final int boardSize = getBoardSize();
   numericCells = new TextView[boardSize][boardSize];
   imageCells = new ImageView[boardSize][boardSize];
   for (int i = 0; i < boardSize; i++) {
     TableRow numericRow = new TableRow(this);
     TableRow imageRow = new TableRow(this);
     for (int j = 0; j < boardSize; j++) {
       TextView numericCell = new TextView(this);
       ImageView imageCell = new ImageView(this);
       numericCells[i][j] = numericCell;
       imageCells[i][j] = imageCell;
       initNumericCell(numericCell);
       initImageCell(imageCell);
       numericRow.addView(numericCell);
       imageRow.addView(imageCell);
     }
     numericBoardView.addView(numericRow);
     imageBoardView.addView(imageRow);
   }
   countDownCell = new TextView(this);
   initNumericCell(countDownCell);
 }
Esempio n. 6
0
  public void bindView(Cursor cursor) {
    // Reinflate layout
    removeAllViewsInLayout();
    View view = LayoutInflater.from(getContext()).inflate(R.layout.sets_table, this);

    TableRow tableRowWeight = (TableRow) view.findViewById(R.id.tableRowWeight);
    TableRow tableRowReps = (TableRow) view.findViewById(R.id.tableRowReps);

    if (cursor != null && cursor.moveToFirst()) {
      do {
        TextView textViewWeight = new TextView(getContext());
        TextView textViewReps = new TextView(getContext());

        textViewWeight.setBackgroundResource(R.drawable.cell_right_border);
        textViewReps.setBackgroundResource(R.drawable.cell_right_top_border);

        textViewWeight.setPadding(4, 0, 5, 0);
        textViewReps.setPadding(4, 0, 5, 0);

        textViewWeight.setGravity(Gravity.CENTER_HORIZONTAL);
        textViewReps.setGravity(Gravity.CENTER_HORIZONTAL);

        tableRowWeight.addView(textViewWeight);
        tableRowReps.addView(textViewReps);

        // Bind data
        float weight = cursor.getFloat(cursor.getColumnIndex(Sets.WEIGHT));
        String reps = cursor.getString(cursor.getColumnIndex(Sets.REPS));

        textViewWeight.setText(SetUtils.weightFormat(weight));
        textViewReps.setText(reps);
      } while (cursor.moveToNext());
    }
  }
    @Override
    protected void onPostExecute(Void v) {

      Log.d("RAWR", "Table Shiz");
      TableLayout tl = (TableLayout) findViewById(R.id.table);

      for (int i = 0; i < labels.size(); i++) {
        TableRow tr = new TableRow(getApplicationContext());

        TextView t1 = new TextView(getApplicationContext());
        t1.setText(labels.get(i));
        t1.setTextColor(Color.BLACK);
        t1.setTypeface(null, Typeface.BOLD);
        tr.addView(t1);

        TextView t2 = new TextView(getApplicationContext());
        t2.setText(data.get(i));
        t2.setGravity(Gravity.RIGHT);
        t2.setTextColor(Color.BLACK);
        tr.addView(t2);

        tl.addView(
            tr, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
      }

      TextView desc = (TextView) findViewById(R.id.description);
      desc.setText("Description: \n\n\t" + description);
      pd.dismiss();
    }
Esempio n. 8
0
  private void addHeader() {
    TableRow rowHeader = new TableRow(getActivity().getBaseContext());
    TextView lblNim = new TextView(getActivity().getBaseContext()),
        lblNama = new TextView(getActivity().getBaseContext());

    lblNim.setText("NIM");
    lblNama.setText("Nama");

    Float pixel1 =
        TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 120, r.getDisplayMetrics());
    Float pixel2 =
        TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 260, r.getDisplayMetrics());

    lblNim.setGravity(Gravity.CENTER_HORIZONTAL);
    lblNama.setGravity(Gravity.CENTER_HORIZONTAL);
    TableRow.LayoutParams param =
        new TableRow.LayoutParams(0, TableRow.LayoutParams.WRAP_CONTENT, 1f);
    lblNama.setLayoutParams(param);
    lblNim.setLayoutParams(param);
    lblNim.setWidth(Math.round(pixel1));
    lblNama.setWidth(Math.round(pixel2));
    lblNim.setTextColor(Color.BLACK);
    lblNama.setTextColor(Color.BLACK);

    rowHeader.addView(lblNim);
    rowHeader.addView(lblNama);
    tblDaftarMhs.addView(rowHeader);
  }
 protected android.view.View onCreateDialogView() {
   android.widget.TableLayout.LayoutParams params;
   android.widget.TableLayout layout = new android.widget.TableLayout(mContext);
   layout.setPadding(6, 6, 6, 6);
   mSplashText = new android.widget.TextView(mContext);
   if (mDialogMessage != null) {
     mSplashText.setText(mDialogMessage);
   }
   android.widget.TableRow row_header = new android.widget.TableRow(mContext);
   row_header.addView(mSplashText);
   mPickInteger = new net.mandaria.tippytipper.widgets.NumberPicker(mContext);
   mPickInteger.setRange(mMin, mMax);
   android.widget.TextView suffix = new android.widget.TextView(mContext);
   suffix.setText(mSuffix);
   suffix.setTextSize(32);
   android.widget.TableRow row_one = new android.widget.TableRow(mContext);
   row_one.setGravity(Gravity.CENTER);
   row_one.addView(mPickInteger);
   row_one.addView(suffix);
   layout.addView(row_header);
   android.widget.TableLayout table_main = new android.widget.TableLayout(mContext);
   table_main.addView(row_one);
   android.widget.TableRow row_main = new android.widget.TableRow(mContext);
   row_main.setGravity(Gravity.CENTER_HORIZONTAL);
   row_main.addView(table_main);
   layout.addView(row_main);
   if (shouldPersist()) {
     mValue = getPersistedInt(mDefault);
   }
   bindData();
   return layout;
 }
Esempio n. 10
0
  private void addTableRow(TableLayout table, String parameter, String value) {

    TableRow row = new TableRow(table.getContext());

    TableRow.LayoutParams trParams = new TableRow.LayoutParams();
    trParams.setMargins(2, 2, 2, 1);
    row.setLayoutParams(trParams);
    row.setBackgroundColor(Color.rgb(0x00, 0x00, 0x00));

    TextView text1 = new TextView(row.getContext());
    text1.setTextSize(18);
    text1.setText(parameter);
    text1.setBackgroundColor(Color.rgb(0x18, 0x18, 0x18));
    text1.setLayoutParams(trParams);
    text1.setPadding(5, 0, 0, 0);
    row.addView(text1);

    TextView text2 = new TextView(row.getContext());
    text2.setTextSize(18);
    text2.setText(value);
    text2.setBackgroundColor(Color.rgb(0x18, 0x18, 0x18));
    text2.setLayoutParams(trParams);
    text2.setPadding(5, 0, 0, 0);
    row.addView(text2);

    table.addView(row);
  }
Esempio n. 11
0
 /**
  * Appends a swatch to the end of the row for even-numbered rows (starting with row 0), to the
  * beginning of a row for odd-numbered rows.
  */
 private static void addSwatchToRow(TableRow row, View swatch, int rowNumber) {
   if (rowNumber % 2 == 0) {
     row.addView(swatch);
   } else {
     row.addView(swatch, 0);
   }
 }
  public void setAllPlayers(List<Player> allPlayers) {
    allPlayersTable.removeAllViews();
    for (final Player player : allPlayers) {
      TableRow playerRow = new TableRow(context);
      playerRow.setLayoutParams(
          new TableRow.LayoutParams(
              TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
      allPlayersTable.addView(playerRow);

      CheckBox playerSelection = new CheckBox(context);
      playerSelection.setChecked(player.isSelected());
      playerSelection.setOnCheckedChangeListener(
          new OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
              isCurrentPlayerSelected = isChecked;
              currentPlayerId = player.getId();
              selectedPlayersChangedListenerManager.notifyListeners();
            }
          });
      playerRow.addView(playerSelection);

      TextView playerName = new TextView(context);
      playerName.setText(player.getName());
      playerName.setTextSize(UIConstants.TEXT_NORMAL_SIZE);
      playerName.setTextColor(UIConstants.TEXT_COLOR);
      playerRow.addView(playerName);
    }
  }
  private void uiAddModeRow(TableLayout tl) {
    TableRow tb = new TableRow(this);
    TextView labelText = new TextView(this);

    Button btnDay = new Button(this);
    Button btnNight = new Button(this);
    Button btnMedia = new Button(this);
    Button btnFirmware = new Button(this);

    labelText.setText("Mode:");

    btnDay.setText("Day");
    btnNight.setText("Night");
    btnMedia.setText("Media");
    btnFirmware.setText("Firmware");

    btnDay.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mBtBand.addRequest(
                BtAction.Action.SET_MODE, BandMode.getInt(BandMode.AccessoryMode.DAY));
          }
        });

    btnNight.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mBtBand.addRequest(
                BtAction.Action.SET_MODE, BandMode.getInt(BandMode.AccessoryMode.NIGHT));
          }
        });

    btnMedia.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mBtBand.addRequest(
                BtAction.Action.SET_MODE, BandMode.getInt(BandMode.AccessoryMode.MEDIA));
          }
        });

    btnFirmware.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mBtBand.addRequest(
                BtAction.Action.SET_MODE, BandMode.getInt(BandMode.AccessoryMode.FIRMWARE_UPDATE));
          }
        });

    tb.addView(labelText);
    tb.addView(btnDay);
    tb.addView(btnNight);
    tb.addView(btnMedia);
    tb.addView(btnFirmware);
    tl.addView(tb);
  }
Esempio n. 14
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;
    }
  }
  public TableLayout createTable() {
    int comboCounter = 0;
    TableLayout tl = new TableLayout(this);
    TableRow tr = new TableRow(this);
    CheckBox c;
    TextView text;
    for (int x = 0; x < KMapControl.getTopDisplay().length; x++) {
      text = new TextView(this);
      if (KMapControl.getKMapSize() == KMapController.VARIABLE_5) {
        if (x == 0) {
          fiveVarCounter += 1;
          text.setTextColor(Color.YELLOW);
          text.setText(fiveVarCounter + "  ");
        } else text.setText(KMapControl.getTopDisplay()[x]);
      } else {
        text.setText(KMapControl.getTopDisplay()[x]);
      }
      text.setPadding(PADDING, PADDING, PADDING, PADDING);
      tr.addView(text);
    }
    tl.addView(tr);

    for (int x = 0; x < KMapControl.getLeftDisplay().length; x++) {
      tr = new TableRow(this);
      text = new TextView(this);
      text.setText(KMapControl.getLeftDisplay()[x]);
      text.setPadding(PADDING, PADDING, PADDING, PADDING);
      tr.addView(text);

      for (int y = 1; y < KMapControl.getTopDisplay().length; y++) {
        c = new CheckBox(this);
        if (KMapControl.getKMapSize() == KMapController.VARIABLE_5 && fiveVarCounter == 1)
          c.setId(KMapControl.getTableLayout()[comboCounter] + 16);
        else c.setId(KMapControl.getTableLayout()[comboCounter]);
        c.setButtonDrawable(R.drawable.customcheck);
        c.setPadding(PADDING, PADDING, PADDING, PADDING);

        c.setOnCheckedChangeListener(
            new OnCheckedChangeListener() {

              @Override
              public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
                KMapControl.setVariableAtLocation(arg0.getId(), arg1);
                String s = "\nLast Selected:\n\nMinterm: " + arg0.getId() + "\n" + "State: ";
                if (arg1 == false) s += "0";
                else s += "1";
                s += "\nBinary: " + KMapControl.getBinarySpot(arg0.getId());
                s += "\nVariables: " + KMapControl.getStringVariableAtLocation(arg0.getId());
                display.setText(s);
              }
            });
        tr.addView(c);
        comboCounter += 1;
      }
      tl.addView(tr);
    }
    return tl;
  }
  public void setTable(Integer i) {
    final Integer index = i;
    TableRow row = new TableRow(getActivity().getApplicationContext());
    TableRow.LayoutParams lp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT);
    row.setLayoutParams(lp);

    final TextView cp = new Button(getActivity().getApplicationContext());
    cp.setAllCaps(false);
    cp.setText(wordRecordArrayList.get(i).getchin_word());
    //        cp.setText(i.toString());
    cp.setPadding(20, 0, 30, 0);
    cp.setBackgroundResource(R.drawable.borders_black_and_blue);
    cp.setTextSize(40);
    cp.setGravity(Gravity.CENTER);
    row.addView(cp);

    TextView tone = new TextView(getActivity().getApplicationContext());
    tone.setText(wordRecordArrayList.get(i).getTone().toString());
    tone.setTextSize(30);
    tone.setPadding(100, 0, 30, 0);
    tone.setTextColor(Color.BLACK);
    row.addView(tone);

    TextView turnOff = new TextView(getActivity().getApplicationContext());
    turnOff.setText("關閉");
    turnOff.setTextSize(15);
    turnOff.setPadding(100, 0, 30, 0);
    turnOff.setTextColor(Color.BLACK);
    turnOff.setGravity(Gravity.CENTER);
    turnOff.setVisibility(View.INVISIBLE);
    row.addView(turnOff);

    Switch switch1 = new Switch(getActivity().getApplicationContext());
    switch1.setSwitchMinWidth(200);
    switch1.setPadding(0, 0, 0, 0);
    switch1.setGravity(Gravity.CENTER);
    switch1.setVisibility(View.INVISIBLE);
    if (wordRecordArrayList.get(i).getAvailable().intValue() == 1) {
      switch1.setChecked(true);
    } else {
      switch1.setChecked(false);
    }
    row.addView(switch1);

    TextView turnOn = new TextView(getActivity().getApplicationContext());
    turnOn.setText("開啟");
    turnOn.setTextSize(15);
    turnOn.setPadding(30, 0, 30, 0);
    turnOn.setTextColor(Color.BLACK);
    turnOn.setGravity(Gravity.CENTER);
    turnOn.setVisibility(View.INVISIBLE);
    row.addView(turnOn);

    delRecord(i, row, cp);
    setAvailability(row, turnOn, turnOff, switch1, index);
    tl_word.addView(row);
  }
Esempio n. 17
0
  // suppress this error message to be able to use spaces in higher api levels
  @SuppressLint("NewApi")
  public void refresh() {

    if (mAdapter == null) {
      mAdapter = new StackAdapter(mContext, mStacks, mSwipeable);
      if (mListView != null) {
        mListView.setAdapter(mAdapter);
      } else if (mTableLayout != null) {
        TableRow tr = null;
        for (int i = 0; i < mAdapter.getCount(); i += mColumnNumber) {
          // add a new table row with the current context
          tr = new TableRow(mTableLayout.getContext());
          tr.setOrientation(TableRow.HORIZONTAL);
          tr.setLayoutParams(
              new TableRow.LayoutParams(
                  TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
          // add as many cards as the number of columns indicates per row
          for (int j = 0; j < mColumnNumber; j++) {
            if (i + j < mAdapter.getCount()) {
              View card = mAdapter.getView(i + j, null, tr);
              if (card.getLayoutParams() != null) {
                card.setLayoutParams(
                    new TableRow.LayoutParams(
                        card.getLayoutParams().width, card.getLayoutParams().height, 1f));
              } else {
                card.setLayoutParams(
                    new TableRow.LayoutParams(
                        TableRow.LayoutParams.MATCH_PARENT,
                        TableRow.LayoutParams.WRAP_CONTENT,
                        1f));
              }
              tr.addView(card);
            }
          }
          mTableLayout.addView(tr);
        }
        if (tr != null) {
          // fill the empty space with spacers
          for (int j = mAdapter.getCount() % mColumnNumber; j > 0; j--) {
            View space = null;
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
              space = new Space(tr.getContext());
            } else {
              space = new View(tr.getContext());
            }
            space.setLayoutParams(
                new TableRow.LayoutParams(
                    TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT, 1f));
            tr.addView(space);
          }
        }
      }
    } else {
      mAdapter.setSwipeable(mSwipeable); // in case swipeable changed;
      mAdapter.setItems(mStacks);
    }
  }
Esempio n. 18
0
 // 排行榜增加一条记录的方法
 public void addRows(String rank, String name, String score, TableLayout tl) {
   TableRow tablerow = new TableRow(this);
   TextView rrank = new TextView(this);
   rrank.setText(rank);
   TextView rname = new TextView(this);
   rname.setText(name);
   TextView rscore = new TextView(this);
   rscore.setText(score);
   tablerow.addView(rrank);
   tablerow.addView(rname);
   tablerow.addView(rscore);
   tl.addView(tablerow);
 }
  /** create dynamic table layout and fill it with data of activity index. */
  private void loadIndex() {

    // get dao
    Dao<LocationData, Integer> locationDao = null;

    int index = 1;
    int left = 3, top = 3, right = 3, bottom = 3;

    // first clean the table except first row
    table.removeViews(index, (table.getChildCount() - 1));

    // query for all of the data objects in the database
    List<LocationData> list;
    try {
      locationDao = getHelper().getLocationDao();
      list = locationDao.queryForAll();
      for (LocationData data : list) {

        TableRow row = new TableRow(this);

        TextView viewID = new TextView(this);
        viewID.setPadding(left, top, right, bottom);
        viewID.setText(data.getId().toString());
        row.addView(viewID);

        TextView viewLongitude = new TextView(this);
        viewLongitude.setPadding(left, top, right, bottom);
        viewLongitude.setText(String.valueOf(data.getLongitude()));
        row.addView(viewLongitude);

        TextView viewLatitude = new TextView(this);
        viewLatitude.setPadding(left, top, right, bottom);
        viewLatitude.setText(String.valueOf(data.getLatitude()));
        row.addView(viewLatitude);

        TextView viewTimestamp = new TextView(this);
        viewTimestamp.setPadding(left, top, right, bottom);
        viewTimestamp.setText(data.getTimestamp().toLocaleString());
        row.addView(viewTimestamp);

        table.addView(row, index);
        index++;
      }
    } catch (SQLException e) {
      Log.e(TAG, "Could not read data");
      e.printStackTrace();
    } finally {

    }
  }
  public void start() {
    setContentView(R.layout.game_matrix_layout);
    matrika = new ImageButton[vrstice][stolpci];

    TableLayout tlMatrika = (TableLayout) findViewById(R.id.tableLayoutMatrika);
    for (int i = 0; i < vrstice; i++) {
      TableRow tr = new TableRow(this);
      tlMatrika.addView(tr);
      for (int j = 0; j < stolpci; j++) {
        final int vrstica = i;
        final int stolpec = j;
        final ImageButton ib = new ImageButton(this);
        ib.setAdjustViewBounds(true);
        ib.setImageResource(R.drawable.blank);
        ib.setMaxHeight(60);
        ib.setScaleType(ScaleType.CENTER_INSIDE);

        matrika[i][j] = ib;

        ib.setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {
                pozicijaVrstica = vrstica;
                pozicijaStolpec = stolpec;
              }
            });
        tr.addView(ib);
      }
    }

    NIgra ni = new NIgra(this, matrika, mHandler, msgHandler);
    ni.start();
  }
Esempio n. 21
0
 public void otherSearchEditTextInflater(TableRow tableRow) {
   LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
   View otherSearchEditTextView = inflater.inflate(R.layout.custom_edit_text_layout, null);
   otherSearchEditText = (EditText) otherSearchEditTextView.findViewById(R.id.customEditText);
   otherSearchEditText.setHint("Enter Search Term Here");
   tableRow.addView(otherSearchEditTextView);
 }
Esempio n. 22
0
  private void newGame(int c, int r) {
    ROW_COUNT = r;
    COL_COUNT = c;

    cards = new int[COL_COUNT][ROW_COUNT];

    mainTable.removeView(findViewById(R.id.TableRow01));
    mainTable.removeView(findViewById(R.id.TableRow02));

    TableRow tr = ((TableRow) findViewById(R.id.TableRow03));
    tr.removeAllViews();

    mainTable = new TableLayout(context);
    tr.addView(mainTable);

    for (int y = 0; y < ROW_COUNT; y++) {
      mainTable.addView(createRow(y));
    }

    firstCard = null;
    loadCards();

    turns = 0;
    ((TextView) findViewById(R.id.tv1)).setText("ចននបកលង: " + turns);
  }
  @Override
  protected void onResume() {
    super.onResume();
    CustomElementManager.refresh(this);
    ArrayList<CustomElement> elements = CustomElementManager.getElementList();

    // Clear the existing list
    TableLayout tl = (TableLayout) findViewById(R.id.loads_container);
    tl.removeAllViews();

    // Go through and find all the save files and dynamically add them
    int length = elements.size();
    if (length != 0) {
      for (int i = 0; i < length; i++) {
        addEntity(elements.get(i).getName(), elements.get(i).getFilename());
      }
    } else {
      tr = new TableRow(this);
      tr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
      tr.setGravity(Gravity.CENTER);

      TextView tv = new TextView(this);
      tv.setText(res.getText(R.string.no_elements));

      tr.addView(tv);
      tl.addView(tr);
    }
  }
Esempio n. 24
0
 private void addText(TableRow r, String s, boolean isChecked, boolean isRight, Long sessionId) {
   TextView c = new TextView(this);
   c.setText(s);
   if (isChecked) {
     c.setTypeface(null, Typeface.BOLD);
     c.setTextColor(Color.WHITE);
   }
   if (isRight) {
     c.setGravity(Gravity.RIGHT);
   }
   controls.put(c, sessionId);
   c.setOnTouchListener(
       new OnTouchListener() {
         @Override
         public boolean onTouch(View v, MotionEvent event) {
           if (event.getAction() == MotionEvent.ACTION_DOWN) {
             Long sessionId = controls.get(v);
             if (sessionId != null) {
               Uri uri = ContentUris.withAppendedId(PuzzleDb.Sessions.CONTENT_URI, sessionId);
               setResult(RESULT_OK, new Intent().setData(uri));
               finish();
               return true;
             }
           }
           return false;
         }
       });
   r.addView(c);
 }
 public void addTableBody(TableLayout table) {
   Cursor cursor = mySQLiteHelper.executeQuery(this.buildTableQuery());
   int row = 0;
   if (cursor != null && cursor.moveToFirst()) {
     do {
       TableRow tr = new TableRow(getActivity());
       tr.setGravity(Gravity.CENTER);
       for (int i = 0; i < columnNames.length; i++) {
         String value = cursor.getString(cursor.getColumnIndex(columnNames[i]));
         TextView tv = getCellTextView(value, row);
         tr.addView(tv);
       }
       table.addView(tr);
       Long id = cursor.getLong(cursor.getColumnIndex("_id"));
       tr.setTag(id);
       tr.setOnClickListener(
           new View.OnClickListener() {
             @Override
             public void onClick(View v) {
               Long id = Long.valueOf(v.getTag().toString());
               String xml = formBuilder.buildFormSubmissionXMLString(form, id);
               ((FormDataActivity) getActivity()).switchToDisplayFormFragment(1, xml);
             }
           });
       row++;
     } while (cursor.moveToNext());
   }
 }
  private void initGameBoard() {

    mTableLayout = (TableLayout) findViewById(R.id.table_layout);
    mTableLayout.setStretchAllColumns(true);
    // mTableLayout.setBackgroundResource(R.color.blue);

    int counter = 1;
    for (int row = 0; row < 3; row++) {
      TableRow tableRow = new TableRow(this);
      for (int col = 0; col < 3; col++) {

        Button button = new Button(this);

        button.setTag(counter);

        // button.setText(row+","+col+"\nTag:"+button.getTag());

        button.setOnClickListener(this);
        button.setWidth(300);
        button.setHeight(300);
        button.setTextSize(40);

        tableRow.addView(button);

        counter++;
      }

      mTableLayout.addView(tableRow, new TableLayout.LayoutParams(FP, WC));
    }
  }
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   ScrollView sv = new ScrollView(this.getActivity().getApplicationContext());
   TableLayout tableLayout = new TableLayout(this.getActivity().getApplicationContext());
   sv.addView(tableLayout);
   TableRow tableRow;
   TextView textView;
   File dir = new File(Environment.getExternalStorageDirectory() + "/PhotoAR/");
   File[] filelist = dir.listFiles();
   //			f.getName()
   //		{ // do your stuff here }
   if (filelist != null) {
     for (File f : filelist) {
       tableRow = new TableRow(this.getActivity().getApplicationContext());
       textView = new TextView(this.getActivity().getApplicationContext());
       Calendar cal = Calendar.getInstance(Locale.ENGLISH);
       cal.setTimeInMillis(Long.valueOf(f.getName().replace(".jpg", "")));
       String date = DateFormat.format("dd-MM-yyyy hh:mm:ss", cal).toString();
       ExifInterface exif = null;
       String message = "";
       try {
         exif = new ExifInterface(f.getCanonicalPath());
         message = exif.getAttribute("UserComment");
       } catch (IOException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
       }
       textView.setText(date + " " + message);
       textView.setPadding(20, 20, 20, 20);
       tableRow.addView(textView);
       tableLayout.addView(tableRow);
     }
   } else {
     tableRow = new TableRow(this.getActivity().getApplicationContext());
     textView = new TextView(this.getActivity().getApplicationContext());
     textView.setText("[No Submissions]");
     textView.setPadding(20, 20, 20, 20);
     tableRow.addView(textView);
     tableLayout.addView(tableRow);
   }
   //		setContentView(tableLayout);
   View rootView = sv;
   //		View rootView = inflater.inflate(R.layout.coming_soon_layout, container, false);
   return rootView;
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    ScrollView sv = new ScrollView(getActivity());
    TableLayout tl = new TableLayout(getActivity());
    sv.addView(tl);

    if (displayReportController == null) {
      return sv;
    }
    AdsenseReportsGenerateResponse response = displayReportController.getReportResponse();

    TableLayout.LayoutParams tableRowParams =
        new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    tableRowParams.setMargins(10, 10, 10, 10);

    TableRow.LayoutParams tvParams =
        new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    tvParams.setMargins(10, 10, 10, 10);

    List<Headers> headers = response.getHeaders();
    TableRow tr = new TableRow(getActivity());
    tl.addView(tr);

    for (Headers header : headers) {
      TextView tv = new TextView(getActivity());
      tv.setText(header.getName());
      tr.setLayoutParams(tableRowParams);
      tr.addView(tv);
    }
    if (response.getRows() != null && !response.getRows().isEmpty()) {
      for (List<String> row : response.getRows()) {
        TableRow trow = new TableRow(getActivity());
        tl.addView(trow);
        for (String cell : row) {
          TextView tv = new TextView(getActivity());
          tv.setText(cell);
          trow.addView(tv);
          tv.setLayoutParams(tvParams);
          tv.setPadding(15, 5, 15, 5);
          tv.setBackgroundColor(Color.WHITE);
        }
      }
    }
    return sv;
  }
Esempio n. 29
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);
 }
Esempio n. 30
0
 private void addTextToRowWithValues(
     final TableRow tableRow, String text, int textColor, float textSize) {
   TextView textView = new TextView(this);
   textView.setTextSize(textSize);
   textView.setTextColor(textColor);
   textView.setText(text);
   tableRow.addView(textView);
 }