@Override
  public void onCreate(Context ctx) {

    LinearLayout linearLayout = new LinearLayout(ctx);
    linearLayout.setOrientation(LinearLayout.VERTICAL);

    // beds
    Spinner spinnerTextField = new Spinner(ctx);
    ArrayAdapter<Integer> aa =
        new ArrayAdapter<Integer>(
            ctx, android.R.layout.simple_spinner_item, new Integer[] {1, 2, 3});
    aa.setDropDownViewResource(android.R.layout.select_dialog_singlechoice);
    spinnerTextField.setAdapter(aa);
    spinnerTextField.setOnItemSelectedListener(bedCountSpinnerItemSelectionListener);

    // options
    TableLayout amenitiesLayout = new TableLayout(ctx);
    amenitiesLayout.setColumnStretchable(0, false);
    amenitiesLayout.setColumnShrinkable(1, true);
    Amenity[] ams = Amenity.values();
    for (Amenity amenity : ams) {
      TableRow tableRow = buildAmenityTableRow(ctx, amenity);
      amenitiesLayout.addView(tableRow);
    }

    linearLayout.addView(
        Utils.buildLabelAndField(ctx, ctx.getString(R.string.beds_label), spinnerTextField));
    linearLayout.addView(
        Utils.buildLabelAndField(ctx, ctx.getString(R.string.amenities_label), amenitiesLayout));

    addView(linearLayout);
  }
Exemple #2
0
  /** @see android.app.Activity#onOptionsItemSelected(android.view.MenuItem) */
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case 0:
        // Go back to the map page
        finish();
        return true;
      case 1:
        // Sort the list by job title
        for (View vw : lstTable) {
          tblJobs.removeView(vw);
        }
        fillData(JobsCursor.SortBy.title);
        return true;
      case 2:
        // Sort the list by employer name
        for (View vw : lstTable) {
          tblJobs.removeView(vw);
        }
        fillData(JobsCursor.SortBy.employer_name);
        return true;
      case 3:
        // Add a new job
        Intent i = new Intent(MicroJobsList.this, AddJob.class);
        startActivity(i);
        return true;
    }

    return false;
  }
  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);
  }
  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();
  }
 private void updateUi(Receiver receiver) {
   if (receiver == null) {
     layoutMasterSlave.setVisibility(View.GONE);
     layoutDip.setVisibility(View.GONE);
     layoutAutoPair.setVisibility(View.GONE);
     layoutUniversal.setVisibility(View.GONE);
   } else if (Receiver.TYPE_AUTOPAIR.equals(receiver.getType())) {
     layoutMasterSlave.setVisibility(View.GONE);
     layoutDip.setVisibility(View.GONE);
     layoutAutoPair.setVisibility(View.VISIBLE);
     layoutUniversal.setVisibility(View.GONE);
   } else if (Receiver.TYPE_DIPS.equals(receiver.getType())) {
     layoutMasterSlave.setVisibility(View.GONE);
     layoutDip.setVisibility(View.VISIBLE);
     layoutAutoPair.setVisibility(View.GONE);
     layoutUniversal.setVisibility(View.GONE);
   } else if (Receiver.TYPE_MASTER_SLAVE.equals(receiver.getType())) {
     layoutMasterSlave.setVisibility(View.VISIBLE);
     layoutDip.setVisibility(View.GONE);
     layoutAutoPair.setVisibility(View.GONE);
     layoutUniversal.setVisibility(View.GONE);
   } else if (Receiver.TYPE_UNIVERSAL.equals(receiver.getType())) {
     layoutMasterSlave.setVisibility(View.GONE);
     layoutDip.setVisibility(View.GONE);
     layoutAutoPair.setVisibility(View.GONE);
     layoutUniversal.setVisibility(View.VISIBLE);
   }
 }
Exemple #6
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);
  }
  void populateMatchesTable(ArrayList<Match> matches) {
    TableLayout tl = ((TableLayout) findViewById(R.id.upcomingMatches));

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

    findViewById(R.id.loadingRow).setVisibility(View.GONE);

    for (final Match m : matches) {
      TableRow tr = (TableRow) inflater.inflate(R.layout.match_row, null);

      if (m.r1.equals(Constants.teamNumber)
          || m.r2.equals(Constants.teamNumber)
          || m.r3.equals(Constants.teamNumber)
          || m.b1.equals(Constants.teamNumber)
          || m.b2.equals(Constants.teamNumber)
          || m.b3.equals(Constants.teamNumber)) {
        tr.setBackgroundColor(Color.parseColor("#e3e3e3"));
      }

      ((TextView) tr.findViewById(R.id.r0)).setText(m.r1);
      ((TextView) tr.findViewById(R.id.r1)).setText(m.r2);
      ((TextView) tr.findViewById(R.id.r2)).setText(m.r3);

      ((TextView) tr.findViewById(R.id.b0)).setText(m.b1);
      ((TextView) tr.findViewById(R.id.b1)).setText(m.b2);
      ((TextView) tr.findViewById(R.id.b2)).setText(m.b3);

      ((TextView) tr.findViewById(R.id.redScore)).setText(m.redScore);
      ((TextView) tr.findViewById(R.id.blueScore)).setText(m.blueScore);

      ((TextView) tr.findViewById(R.id.matchDisplay)).setText(m.matchNumber);

      tl.addView(tr);
    }
  }
  @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);
    }
  }
Exemple #9
0
        @Override
        public void onClick(View arg0) {
          hideSoftKeyboard();
          if (adSearchNotEditText.getText().length() > 0) {
            LayoutInflater inflater =
                (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View notTermsView = inflater.inflate(R.layout.added_terms_layout, null);

            if (!notTermsPresent) {
              View notTitleView = inflater.inflate(R.layout.title_layout, null);
              TextView notTitle = (TextView) notTitleView.findViewById(R.id.newTitleTextView);
              notTitle.setText(R.string.not_title);
              adSearchNotTableLayout.addView(notTitleView);
              notTermsPresent = true;
            }

            TextView newTerm = (TextView) notTermsView.findViewById(R.id.newTermTextView);
            newTerm.setText(adSearchNotEditText.getText().toString());
            Button newDeleteButton = (Button) notTermsView.findViewById(R.id.newRemoveTermButton);
            newDeleteButton.setOnClickListener(deleteButtonListener);

            // Add to the notTerms Arraylist
            notTerms.add(adSearchNotEditText.getText().toString());
            adSearchNotEditText.setText("");
            adSearchNotTableLayout.addView(notTermsView, 1);
            notTermsCount++;
          }
        }
Exemple #10
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);
    }
  }
  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);
    }
  }
Exemple #12
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);
      }
    }
  }
  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));
    }
  }
  @Test
  public void should_show_statistics_on_first_question_of_resume_game()
      throws IOException, ItemException {

    Set<Integer> answeredItemId = new HashSet<Integer>();
    answeredItemId.add(0);
    Set<Integer> goodAnsweredItemId = new HashSet<Integer>();
    goodAnsweredItemId.add(0);
    Stats stats = new Stats(answeredItemId, goodAnsweredItemId);

    GameState gameState = new GameState(Arrays.asList(1, 2));

    commonExpectsInitGame(gameState, stats);

    expect(repositoryItemsCache.getItem(GameState.class)).andReturn(gameState);
    expect(repositoryItemsCache.getItem(Stats.class)).andReturn(stats);

    testModule.replay();

    quizzActivity.onCreate(null);

    quizzActivity.findViewById(R.id.buttonResumeGame).performClick();

    TableLayout footerTable = (TableLayout) quizzActivity.findViewById(R.id.footerTable);
    TextView score = (TextView) quizzActivity.findViewById(R.id.ScoreTextView);
    assertEquals(View.VISIBLE, footerTable.getVisibility());
    assertEquals("Score: 1 / 3", score.getText().toString());
  }
  public void setSelected(int newState) {
    RelativeLayout.LayoutParams lp =
        (RelativeLayout.LayoutParams) mToggleSelector.getLayoutParams();
    lp.topMargin = (mTableLayout.getMeasuredHeight() - heightItem) / 2;
    lp.leftMargin = newState * widthItem + mTableLayout.getPaddingLeft();
    mToggleSelector.setLayoutParams(lp);

    if (Build.VERSION.SDK_INT < 11) {
      AlphaAnimation animation = new AlphaAnimation((float) 0.2, (float) 0.2);
      animation.setDuration(0);
      animation.setFillAfter(true);
      for (ImageView view : buttonList) {
        view.startAnimation(animation);
      }
      currentState = newState;
      animation = new AlphaAnimation(1, 1);
      animation.setDuration(0);
      animation.setFillAfter(true);
      buttonList.get(currentState).startAnimation(animation);
    } else {
      for (ImageView view : buttonList) {
        view.setAlpha((float) 0.2);
      }
      currentState = newState;
      buttonList.get(currentState).setAlpha((float) 1);
    }
  }
  private void alertUser() {
    View view1 = ((Activity) context).getLayoutInflater().inflate(R.layout.popup_layout, null);
    TableLayout contentArea = (TableLayout) view1.findViewById(R.id.contentArea);
    TextView content = new TextView(view1.getContext());
    content.setText(R.string.cancelUploading);
    content.setTextSize(20f);
    contentArea.addView(content);

    setTextView(view1, R.id.title, context.getResources().getString(R.string.alert));

    AlertDialog dialog =
        new AlertDialog.Builder(context)
            .setView(view1)
            .setPositiveButton(
                R.string.ok,
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialogInterface, int i) {
                    cancel(true);
                  }
                })
            .setNegativeButton(
                R.string.cancel,
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialogInterface, int i) {
                    progressDialog.show();
                  }
                })
            .create();

    dialog.show();
  }
Exemple #17
0
        @Override
        public void onClick(View arg0) {
          hideSoftKeyboard();

          if (adSearchMustEditText.getText().length() > 0) {

            LayoutInflater termsInflater =
                (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View termsView = termsInflater.inflate(R.layout.added_terms_layout, null);
            TextView newTerm = (TextView) termsView.findViewById(R.id.newTermTextView);
            Button newDeleteButton = (Button) termsView.findViewById(R.id.newRemoveTermButton);
            newDeleteButton.setOnClickListener(deleteButtonListener);
            // String termText =
            // "\""+adSearchMustEditText.getText().toString()+"\"";
            newTerm.setText(adSearchMustEditText.getText().toString());
            // Adding to mustTerms Array;
            mustTerms.add(adSearchMustEditText.getText().toString());
            adSearchMustEditText.setText("");
            // If terms are not present
            if (!mustTermsPresent) {
              View titleView = termsInflater.inflate(R.layout.title_layout, null);
              TextView newTitle = (TextView) titleView.findViewById(R.id.newTitleTextView);
              newTitle.setText(R.string.must_title);
              adSearchMustTableLayout.addView(titleView);
              mustTermsPresent = true; // Set this value to true
            }

            adSearchMustTableLayout.addView(termsView, 1);
            mustTermsCount++;
          }
        }
    @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();
    }
  public void refreshCallList(Resources resources) {
    if (callsList == null) {
      return;
    }

    callsList.removeAllViews();
    int index = 0;

    if (LinphoneManager.getLc().getCallsNb() == 0) {
      goBackToDialer();
      return;
    }

    isConferenceRunning = LinphoneManager.getLc().getConferenceSize() > 1;
    if (isConferenceRunning) {
      displayConferenceHeader();
      index++;
    }
    for (LinphoneCall call : LinphoneManager.getLc().getCalls()) {
      displayCall(resources, call, index);
      index++;
    }

    if (LinphoneManager.getLc().getCurrentCall() == null) {
      showAudioView();
    }

    callsList.invalidate();
  }
Exemple #20
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);
  }
 /**
  * Starts SIRI JSON bus stop data retrieval from föli's database and clears the previous data from
  * scrollable tablelayout
  */
 public void GetStopData() {
   TableLayout scrollableLayout = (TableLayout) findViewById(R.id.ScrollableTableLayout);
   scrollableLayout.removeAllViews();
   String url = "http://data.foli.fi/siri/sm/" + busNumber;
   // EditText userInput = (EditText) findViewById(R.id.editText);
   // String url = "http://data.foli.fi/siri/sm/"+userInput.getText();
   new ProcessJSON().execute(url);
 }
  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 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 void showInputBeneficiary(boolean input) {
   if (input) {
     beneficiary_rg.setVisibility(View.GONE);
     input_benificiary_content.setVisibility(View.VISIBLE);
   } else {
     beneficiary_rg.setVisibility(View.VISIBLE);
     input_benificiary_content.setVisibility(View.GONE);
   }
 }
Exemple #25
0
 public void someMethod(Item item) {
   setTag(item);
   table.removeAllViews();
   scrollView.scrollTo(0, 0);
   header.render(item);
   for (Item child : item.getChildren()) {
     table.addView(getRowView(child));
   }
 }
 private BaseSkillEditor findSkillEditor(ISkill sk) {
   TableLayout tableSkills = (TableLayout) findViewById(R.id.tableSkills);
   int rows = tableSkills.getChildCount();
   for (int i = 0; i < rows; i++) {
     BaseSkillEditor editor = (BaseSkillEditor) tableSkills.getChildAt(i);
     if (editor.isEditorFor(sk)) return editor;
   }
   return null;
 }
  /** 打开配置对话框. */
  public void openSettingDlg() {
    daemonSignal++;
    spinnerStop();
    if (settingDialog != null && settingDialog.isShowing()) {
      return;
    }

    Builder settingBuilder = new AlertDialog.Builder(this);
    settingBuilder.setTitle(R.string.settingDlgTitle);
    final TableLayout loginSettingForm =
        (TableLayout) getLayoutInflater().inflate(R.layout.settingdlg, null);
    settingBuilder.setView(loginSettingForm);
    settingBuilder.setPositiveButton(
        R.string.save,
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            String url =
                StringUtils.toBj(
                    ((EditText) loginSettingForm.findViewById(R.id.url)).getText().toString());
            String newUser =
                ((EditText) loginSettingForm.findViewById(R.id.userName)).getText().toString();
            String newPassword =
                ((EditText) loginSettingForm.findViewById(R.id.password)).getText().toString();

            sharedEditor.putString(F_URL, url);
            sharedEditor.putString(F_USERNAME, newUser);
            sharedEditor.putString(F_PASSWORD, newPassword);
            sharedEditor.commit();
            contentWebView.clearView();
            dialog.dismiss();
            loadSystem();
          }
        });
    settingBuilder.setNegativeButton(
        R.string.close,
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            System.out.println(loadSuccess);
            System.out.println(PortalActivity.this.loadSuccess);
            if (!loadSuccess) {
              confirmExit();
            }
          }
        });

    String url = sharedPreferences.getString(F_URL, DF_URL);
    url = StringUtils.toBj(url);
    String userName = sharedPreferences.getString(F_USERNAME, DF_USERNAME);
    String password = sharedPreferences.getString(F_PASSWORD, DF_PASSWORD);

    ((EditText) loginSettingForm.findViewById(R.id.url)).setText(url);
    ((EditText) loginSettingForm.findViewById(R.id.userName)).setText(userName);
    ((EditText) loginSettingForm.findViewById(R.id.password)).setText(password);
    settingDialog = settingBuilder.create();
    settingDialog.show();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // 声明二维数组
    String[][] strs = new String[5][3];
    String str = null;
    // 创建Tablelayout
    tableLayout = new TableLayout(this);
    tableLayout.setOrientation(TableLayout.VERTICAL);
    // 设定tablelayout宽高属性
    TableLayout.LayoutParams lp =
        new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    // 绑定参数
    tableLayout.setLayoutParams(lp);

    for (int i = 1; i <= strs.length; i++) {
      // 创建tablerow
      TableRow tableRow = new TableRow(this);
      tableRow.setOrientation(TableRow.HORIZONTAL);
      tableRow.setBackgroundColor(Color.GREEN);
      // 设定tablerow的宽高
      TableRow.LayoutParams trLp =
          new TableRow.LayoutParams(
              TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT);
      tableRow.setLayoutParams(trLp);

      for (int j = 1; j <= strs[0].length; j++) {
        str = "第" + i + "行," + "第" + j + "列";

        TextView mtView = new TextView(this);

        // 添加textview文本信息
        mtView.setText(str);

        if (j == 1) {
          mtView.setBackgroundColor(Color.RED);
        } else if (j == 2) {
          mtView.setBackgroundColor(Color.GREEN);
        } else if (j == 3) {
          mtView.setBackgroundColor(Color.BLUE);
        }
        // 设定textview宽高以及权重

        TableRow.LayoutParams tvLp =
            new TableRow.LayoutParams(0, TableRow.LayoutParams.WRAP_CONTENT, 1);
        // 给textview设定参数
        mtView.setLayoutParams(tvLp);

        // 将textview添加至tablerwo中
        tableRow.addView(mtView);

        Toast.makeText(this, str, 1).show();
      }
      tableLayout.addView(tableRow);
    }
    setContentView(tableLayout);
  }
  // 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);
    }
  }
 private void handleCustomView() {
   if (showCustomView) {
     formulaEditorEditText.setVisibility(View.GONE);
     formulaEditorKeyboard.setVisibility(View.GONE);
   } else {
     formulaEditorEditText.setVisibility(View.VISIBLE);
     formulaEditorKeyboard.setVisibility(View.VISIBLE);
   }
 }