delphi firemoneky在运行时控制

时间:2017-09-26 14:46:08

标签: android delphi firemonkey

我在运行时动态创建FMX控件以编辑ListBox中的数据:

Screenshot here

除了TComboTrackBarTSpinBox之外,它适用于大多数组件,尽管代码如下,但没有显示任何值。

这里是SpinBox:

// Create the SpinBox
SpinBox:= TSpinBox.Create(InternalLayout);
With SpinBox do
begin
  Parent:= InternalLayout;
  Name:= 'sb' + ASubParameter.Name;
  BeginUpdate;
    Align:= TAlignLayout.Client;
    Size.PlatformDefault:= False;
    HitTest:= True;
    Margins.Top:= 1;
    Margins.Bottom:= 1;
    Min:= ASubParameter.Minimum;
    Max:= ASubParameter.Maximum;
    DecimalDigits:= 3;
    KeyboardType:=  TVirtualKeyboardType.NumberPad;
    case AParameter.ParamType of
      TParameterType.ptShortInt, TParameterType.ptInteger:
        begin
          ValueType:= TNumValueType.Integer;
          Value:= ASubParameter.ValueDefault.ToInteger;
        end;
      TParameterType.ptSingle, TParameterType.ptDouble:
        begin
          ValueType:= TNumValueType.Float;
          Value:= ASubParameter.ValueDefault.ToSingle;
        end;
      end;
    Enabled:= not(ASubParameter.ReadOnly);
    OnChange:=  ASubParameter.OnChanged;
  EndUpdate;
end;

在这种情况下,所有SpinBox都应该显示0作为默认值。 如果我点击右箭头,我会得到1.如果我点击左箭头,我得到0。 所以行为是正确的,但控件不能正确显示起始值。

知道我的代码中可能有什么错误或遗漏?

在Windows上,这可以正常工作。在Android上,这不行。

1 个答案:

答案 0 :(得分:0)

这在10.2中修复,在10.1看起来像0是特殊值,对我有用的是先将它分配给其他一些值,例如

SpinBox.Value := 1;
SpinBox.Value := 0;

在这种情况下,值显示

相关问题