Beispiel #1
0
  @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);
  }
  /**
   * @param context
   * @param schedule
   */
  public AttributeRegistryView(Context context, T aAttr) {
    super(context);
    this.attr = aAttr;

    this.setOrientation(VERTICAL);

    TableLayout tableLayout = new TableLayout(context);
    tableLayout.setColumnStretchable(1, true);

    attr.addView(context, tableLayout);
    addView(tableLayout, paramsFillWrap);
  }
Beispiel #3
0
 void dialogShow() {
   dialogLayout.setColumnShrinkable(0, true);
   dialogLayout.setColumnShrinkable(1, true);
   dialogLayout.setColumnStretchable(1, true);
   dialog.show();
 }
  public AddPlayersToGameView(Context context) {
    this.context = context;

    mainScrollView = new ScrollView(context);
    mainScrollView.setFillViewport(true);
    mainScrollView.setLayoutParams(
        new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

    LinearLayout mainView = new LinearLayout(context);
    mainView.setGravity(Gravity.CENTER_HORIZONTAL);
    LinearLayout.LayoutParams mainLayoutParams =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
    mainLayoutParams.leftMargin = UIConstants.MARGIN_SIZE;
    mainLayoutParams.rightMargin = UIConstants.MARGIN_SIZE;
    mainView.setLayoutParams(mainLayoutParams);
    BackgroundUtil.setBackground(mainView);
    mainView.setOrientation(LinearLayout.VERTICAL);
    mainScrollView.addView(mainView);

    TextView title = new TextView(context);
    title.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    title.setText("Add Players");
    title.setTextSize(UIConstants.TEXT_TITLE_SIZE);
    title.setTextColor(UIConstants.TEXT_COLOR);
    title.setGravity(Gravity.CENTER_HORIZONTAL);
    mainView.addView(title);

    LinearLayout controlView = new LinearLayout(context);
    controlView.setGravity(Gravity.CENTER_HORIZONTAL);
    LinearLayout.LayoutParams controlViewLayouParams =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    controlViewLayouParams.leftMargin = UIConstants.MARGIN_SIZE;
    controlViewLayouParams.rightMargin = UIConstants.MARGIN_SIZE;
    controlView.setLayoutParams(controlViewLayouParams);
    controlView.setOrientation(LinearLayout.HORIZONTAL);
    mainView.addView(controlView);

    Button firstDoneButton = new Button(context);
    firstDoneButton.setLayoutParams(
        new LayoutParams(LayoutParams.FILL_PARENT, UIConstants.BUTTON_HEIGHT));
    firstDoneButton.setText("Done");
    firstDoneButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            doneButtonListenerManager.notifyListeners();
          }
        });
    controlView.addView(firstDoneButton);

    allPlayersTable = new TableLayout(context);
    allPlayersTable.setLayoutParams(
        new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

    allPlayersTable.setGravity(Gravity.CENTER_HORIZONTAL);
    TableLayout.LayoutParams allPlayersTableLayoutParams =
        new TableLayout.LayoutParams(
            TableLayout.LayoutParams.FILL_PARENT, TableLayout.LayoutParams.WRAP_CONTENT);
    allPlayersTableLayoutParams.leftMargin = UIConstants.MARGIN_SIZE;
    allPlayersTableLayoutParams.rightMargin = UIConstants.MARGIN_SIZE;
    allPlayersTable.setLayoutParams(allPlayersTableLayoutParams);

    allPlayersTable.setColumnStretchable(1, true);
    mainView.addView(allPlayersTable);

    Button secondDoneButton = new Button(context);
    secondDoneButton.setLayoutParams(
        new LayoutParams(LayoutParams.FILL_PARENT, UIConstants.BUTTON_HEIGHT));
    secondDoneButton.setText("Done");
    secondDoneButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            doneButtonListenerManager.notifyListeners();
          }
        });
    controlView.addView(secondDoneButton);
  }
  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);
    }
  }