Перейти к содержанию
Fire Monkey от А до Я
  • 0

Отсутствует форматирование пользовательских элементов


Alisson R Oliveira

Вопрос

Boa tarde,
eu tenho um problema com o ListView, eu tenho um aplicativo que funciona com elementos de aparência, onde eu adicionar itens manualmente, leva-se a altura da imagem e largura para calcular o tamanho do elemento e a posição dos elementos de comando no elemento. O erro ocorre quando eu altero o controle sobre ele, ele perde toda a sua formatação, por exemplo, oculta um retângulo ou anima o controle.


Alguém já passou por isso? Você sabe como eu posso resolver isso?
Obrigado!

Изменено пользователем Alisson R Oliveira
Ссылка на комментарий

Рекомендуемые сообщения

  • 0

procedure TfrmPrincipal.AdicionarSomenteOfertasLista;
var
  Tarefa: ITask;
begin

  dmDadosLocais.qryListaSomenteOfertas.Active := False;
  dmDadosLocais.qryListaSomenteOfertas.ParamByName('IDOFFSET').AsInteger := TotalSomenteOfertasOFFSET;
  dmDadosLocais.qryListaSomenteOfertas.Active := True;
  dmDadosLocais.qryListaSomenteOfertas.First;

  Tarefa := TTask.Create(
    procedure()
    var
      strOferta, strEmpresa, strSloganEmpresa, strIDOferta: string;
      //
      LItem: TListViewItem;
      //Lista de Imagens
      ItemFolder: TListItemImage;
      Background: TListItemImage;
      LogoMarca: TListItemImage;
      IconeCupom: TListItemImage;
      IconeCurtidas: TListItemImage;
      // Tratablhar com imagens
      ImgStream, ImgStreamLogoEmpresa: TStream;
      ImagemAlterada: TBitmap;
      ImagemBackGround: TBitmap;
      ImagemLogoMarca: TBitmap;
      ImagemCupom: TBitmap;
      UsarCupom: Boolean;
      //Posicionamento
      ItemTituloOferta, ItemEmpresa, ItemSlogan, ItemNumeroCurtidas: TListItemText;
      vKoef: Single;
      AlturaImagem: Single;
      AvailableWidth: Single;
      AlturaLvOfertas: Single;
      Linha: Single;
      //Texto curtidas
      strCurtidas: string;
    begin

      if dmDadosLocais.qryListaSomenteOfertas.RecordCount > 0 then
      begin

        LoadCarregandoSomenteOfertas.Visible := True;

        lvSomenteOfertas.BeginUpdate;

        try

          while not dmDadosLocais.qryListaSomenteOfertas.Eof do
          begin

            strOferta := dmDadosLocais.qryListaSomenteOfertas.FieldByName('oferta').AsString;
            strEmpresa := dmDadosLocais.qryListaSomenteOfertas.FieldByName('empresa').AsString;
            strIDOferta := dmDadosLocais.qryListaSomenteOfertas.FieldByName('id').AsString;
            strSloganEmpresa := dmDadosLocais.qryListaSomenteOfertas.FieldByName('slogan').AsString;
            ImgStream := dmDadosLocais.qryListaSomenteOfertas.CreateBlobStream(dmDadosLocais.qryListaSomenteOfertas.FieldByName('img_media'), TBlobStreamMode.bmRead);
            ImgStreamLogoEmpresa := dmDadosLocais.qryListaSomenteOfertas.CreateBlobStream(dmDadosLocais.qryListaSomenteOfertas.FieldByName('logomarca'), TBlobStreamMode.bmRead);
            //Controle de Cupom
            if dmDadosLocais.qryListaSomenteOfertas.FieldByName('usar_cupom').AsBoolean = True then
              UsarCupom := True
            else if dmDadosLocais.qryListaSomenteOfertas.FieldByName('usar_cupom').AsBoolean = False then
              UsarCupom := False;

            TThread.Synchronize(TThread.CurrentThread,
              procedure()
              begin

                AvailableWidth := lvSomenteOfertas.Width - lvSomenteOfertas.ItemSpaces.Left - lvSomenteOfertas.ItemSpaces.Right;

                ImagemAlterada := TBitmap.Create;
                ImagemAlterada.LoadFromStream(ImgStream);
                {Tamanho e Posicionamento}
                if Handle = nil then
                  exit; // on Android without this user will get Access Violation
                vKoef := AvailableWidth / ImagemAlterada.Width;
                AlturaImagem := ImagemAlterada.Height * vKoef;

                LItem := lvSomenteOfertas.Items.Add;

                LItem.Height := (Round(AlturaImagem) + 5 + 22 + 5 + 40 + 3 + 20 + 30);

                //Atribui valores
                LItem.Data['Oferta'] := strOferta;
                LItem.Data['Empresa'] := strEmpresa;
                LItem.Data['IDOferta'] := strIDOferta;
                LItem.Data['SloganEmpresa'] := strSloganEmpresa;
                strCurtidas := dmDadosLocais.NumeroDeCurtidasFEED(StrToInt(strIDOferta));
                LItem.Data['NumeroCurtidas'] := strCurtidas;
                if strCurtidas.IsEmpty = True then
                  LItem.Data['IconeCurtida'] := 0
                else if strCurtidas.IsEmpty = False then
                  LItem.Data['IconeCurtida'] := 1;

                //Folder
                    ItemFolder := TListItemImage(LItem.View.FindDrawable('Folder'));
                ItemFolder.OwnsBitmap := True;
                ItemFolder.Bitmap := ImagemAlterada;
                ImagemAlterada.Free;
                ItemFolder.Height := AlturaImagem;

                Background := TListItemImage(LItem.View.FindDrawable('Background'));
                Background.Visible := False;


                //LogoEmpresa
                LogoMarca := TListItemImage(LItem.View.FindDrawable('LogoEmpresa'));
                ImagemLogoMarca := TBitmap.Create;
                LogoMarca.OwnsBitmap := True;
                ImagemLogoMarca.LoadFromStream(ImgStreamLogoEmpresa);
                LogoMarca.Bitmap := ImagemLogoMarca;
                ImagemLogoMarca.Free;


              //Icone do Cupom
                IconeCupom := TListItemImage(LItem.View.FindDrawable('iconeCUPOM'));
                ImagemCupom := TBitmap.Create;
                IconeCupom.OwnsBitmap := True;
                if UsarCupom = True then
                  ImagemCupom := imgIconeCupom.Bitmap
                else if UsarCupom = False then
                  ImagemCupom := imgIconeSemCupom.Bitmap;
                IconeCupom.Bitmap := ImagemCupom;
                ImagemCupom.Free;


                //Localiza Objetos
                IconeCurtidas := TListItemImage(LItem.View.FindDrawable('IconeCurtida'));
                ItemTituloOferta := TListItemText(LItem.View.FindDrawable('Oferta'));
                ItemEmpresa := TListItemText(LItem.View.FindDrawable('Empresa'));
                ItemSlogan := TListItemText(LItem.View.FindDrawable('SloganEmpresa'));
                ItemNumeroCurtidas := TListItemText(LItem.View.FindDrawable('NumeroCurtidas'));

                // Posiciona Objetos nos controles
                Linha := 5;

                //Linha 1 - Dados da empresa
                LogoMarca.PlaceOffset.Y := Linha;
                ItemEmpresa.PlaceOffset.Y := Linha;
                ItemEmpresa.PlaceOffset.X := 60;

                ItemSlogan.PlaceOffset.Y := Linha + 21;
                ItemSlogan.PlaceOffset.X := 60;

                //Linha 2 - Folder da Oferta
                Linha := Linha + LogoMarca.Height + 7;
                ItemFolder.PlaceOffset.Y := Linha;

                //Linha 3 - Titulo da oferta
                Linha := Linha + AlturaImagem + 5;
                ItemTituloOferta.PlaceOffset.Y := Linha;

                //Linha 4 - Número de Curtidas
                Linha := Linha + ItemTituloOferta.Height + 3;
                ItemNumeroCurtidas.PlaceOffset.Y := Linha;
                IconeCurtidas.PlaceOffset.Y := Linha;

              end);

            dmDadosLocais.qryListaSomenteOfertas.Next;
          end;

        finally

          lvSomenteOfertas.EndUpdate;
//          if TotalSomenteOfertasOFFSET = 0 then
//            TThread.Synchronize(nil, RepintarOfertasDesalinhadas);

          TotalSomenteOfertasOFFSET := TotalSomenteOfertasOFFSET + 10;

          TThread.Synchronize(TThread.CurrentThread,
            procedure()
            begin
              if TotalSomenteOfertasOFFSET = 10 then
                RepintarOfertasDesalinhadas(lvSomenteOfertas);

              LoadCarregandoSomenteOfertas.Visible := False;
            end);
        end;

      end;

    end);

  Tarefa.Start;

end;

Ссылка на комментарий
  • 0

Good afternoon,
I have a problem with ListView, I have an application that works with dynamic appearance items, where I add items manually, it takes the image height and ListView width to calculate the item size and the position of the elements within the ListView. item. The error occurs when I change some control in the form, it loses all its formatting, for example, hides a rectangle or animates the control.


Has anyone ever experienced this? Do you know how I can solve this?
Thank you!

Ссылка на комментарий
  • 0

Hi there!

Can you show any screenshots?

50 минут назад, Alisson R Oliveira сказал:

Good afternoon,
I have a problem with ListView, I have an application that works with dynamic appearance items, where I add items manually, it takes the image height and ListView width to calculate the item size and the position of the elements within the ListView. item. The error occurs when I change some control in the form, it loses all its formatting, for example, hides a rectangle or animates the control.


Has anyone ever experienced this? Do you know how I can solve this?
Thank you!

 

Ссылка на комментарий
  • 0
4 часа назад, FREEFAR сказал:

Oi ai!

Você pode mostrar alguma captura de tela?

 

I have detailed the error in this image .... the code that adds the items and does its formatting is at the beginning of the tropic. If anyone can help me. appreciate

erro_listview.png

Ссылка на комментарий
  • 0
6 часов назад, FREEFAR сказал:

Have you tollbar align "Top" and listview align "Client"?

How you hide tollbar - Visible := False?

Try toolbar.margin.Top := - toolbar.height

No solutions. It seems to me that with every change in the size of the listview firemonkey re-renders the items ... like formatting and manual (via code) it belongs to everything ... do you have any options so that this does not happen ??

thankful.

Ссылка на комментарий

Присоединяйтесь к обсуждению

Вы можете написать сейчас и зарегистрироваться позже. Если у вас есть аккаунт, авторизуйтесь, чтобы опубликовать от имени своего аккаунта.

Гость
Ответить на вопрос...

×   Вставлено с форматированием.   Вставить как обычный текст

  Разрешено использовать не более 75 эмодзи.

×   Ваша ссылка была автоматически встроена.   Отображать как обычную ссылку

×   Ваш предыдущий контент был восстановлен.   Очистить редактор

×   Вы не можете вставлять изображения напрямую. Загружайте или вставляйте изображения по ссылке.

  • Последние посетители   0 пользователей онлайн

    • Ни одного зарегистрированного пользователя не просматривает данную страницу
×
×
  • Создать...