0
votes

I have a firemonkey multi-device project in Delphi XE8 where I've added a TSearchBox to my TListBox. Only on Android the SearchBox is placed in front of my TListBoxItems. On windows and iOS it displays the searchbox above all the lisboxitems and always stays on top even if you scroll down.

I am using a Nexus 7 with android 5.1.1

In the image below you can see the searchbox in front of the top listboxitem: SearchBox added in fmx

How do i get this with android?

UPDATE

I have created a toolbar above my TListBox and added a searchBox into it at runtime. This way the searchBox is always above the Items but i can't search in the listBox. How do i set it to check the text of the ListBoxItems?

UPDATE 2

I've made a new test project an it seems to work correctly in that project. Now i've tested a bit with the custom style I use and that seems to be the problem. The only problem is that I use a Stylebook to set all the styles in my project and I don't know how to exclude the ListBox and it's items from this.

UPDATE 3

I've deleted the listbox and listboxitem styles from the .style file I use in my StyleBook. This has solved the problem. Only problem I now have is that the TListBoxItem text is displayed. I make custom listboxitems with labels in order to align them a sertain way i want as you can see in the picture below. But in order to be able to search trough the items i need to set the text of the items. So the text is displayed above the labels i set in the item.

Is there a way to set the listboxitem text to invisible? I've already tried to change the color to the same color as the background but this doesn't work and also to set the font size to 0 and this also doesn't work.

3
can you show DFM file?Zam
you create TSearchBox in runtime?Zam
@Zam i've tried creating it runtime and also tried adding it to the fmxRemi
wrt setting listboxitemtext to invisible, I would suggest using the TagString property instead of the Text property.Dsm
Well, no it won't. TSearchBox is not designed for that. You would need to implement your own search that compares the search text with TagString of each item. If you want to use TSearch box you would need to do something like creating a duplicate of the original but with search texts - and building your own search would probably be simpler and more reliable.Dsm

3 Answers

1
votes

cannot reproduce. everything looks the same on Windows and on Android (5.0.2). compiled with Delphi XE7 Update 1.

my pas file:

procedure TForm1.FormCreate(Sender: TObject);
var
  X: TSearchBox;
  I: Integer;
begin
  x := TSearchBox.Create(ListBox1);
  x.Parent := ListBox1;

  for I := 1 to 100 do
    ListBox1.Items.Add('line xxxxxx  yyy');
end;

enter image description here

enter image description here

1
votes

I've created my own search method to search my listBoxItems.

First I gave my listBoxItems a tagString property with the text that i want to be able to search. I use tagString because it's not visible.

Second I've added a searchbox above my TListBox. Then add a keyUp event to the searchBox. This calls my custom search method which only needs the String text from the searchbox.

Code below is my custom search method:

procedure TfrmNocoreDKS.SearchList(text: String);
var
  listItem: TListBoxItem;
  i: Integer;
begin
  CreateList;//Creates all the items in the TListBox
  if not text.isempty then
  begin
    with myListBox do
    begin
      for i := -1 + myListBox.Count downto 0 do
      begin
        listItem := myListBox.ListItems[i];
        if not listItem.TagString.Contains(text) then
        begin
          Items.Delete(i);
        end;
      end;
    end;
  end;
end;
0
votes

I suspect that at some point you modified the Android view instead of the master view. You will need to switch back to the Android view. I believe in XE8 there is an ability to revert to master view from there, but I don't have XE8 so cannot test. Otherwise just move the TSearchBox to where you want it.