Android Question How to use Designer Scripts with PanelList/TabHost

AHilberink

Active Member
Licensed User
Longtime User
Hi,
I do have a PanelList loaded by a TabHost.
Now I want to have a scalable display, so I use Designer Scripts.
It seems the content of the PanelList depends on the TabHost, so I cannot use 100%x or 100%y. I cannot use PanelList.Right or TabHost.Right either because these are on a different display.
Is there a way to calculate this correctly?
I hope I explained it well and someone can help.
Best Regards,
André
 

AHilberink

Active Member
Licensed User
Longtime User
I tried to do it programmaly, but PanelList.Height returns -1. Is there a way to get the real value of the PanelList.Height in dip?

André
 
Upvote 0

AHilberink

Active Member
Licensed User
Longtime User
Hi Erel,

Thanks for your reply. I understand your explanation, but is there a way to get the value of the height of the panellist inside the tab?

Trying:
B4X:
MsgBox(PanelList.Height,"")

Shows a -1

Thanks,
André
 
Upvote 0

AHilberink

Active Member
Licensed User
Longtime User
No. -1 is the value of an Android constant which means that the view fills the available space.

Hi Erel,

Thanks again. I will try to describe my problem, may be you can think of a solution/trick.

I have te following code(part):
B4X:
Sub Zoeken_Click
    If ZoekenZichtbaar = "J" Then
        Zoeksleutel.Visible = False
        StopZoeken.Visible = False
        StartZoeken.Visible = False
        ListView1.Top = 0
        ListView1.Height = PanelList.Height
        Alfabet.Top = 0
        Alfabet.Height = PanelList.Height
        ZoekenZichtbaar = "N"
    Else
        ListView1.Top = 51dip
        'ListView1.Height =
        Alfabet.Top = 51dip
        Alfabet.Height = ListView1.Height
        Zoeksleutel.Visible = True
        StopZoeken.Visible = True
        StartZoeken.Visible = True
        ZoekenZichtbaar = "J"
    End If
End Sub

The ListView1 and button Zoeken are attached to the Layoutfile who is loaded by PanelList (attached to a TabHost).

My problem is with the Else part. As you can see I changed the ListView1.Top. Because the Height isn't recalculated, the bottom of ListView1 is out of my screen. I want to do something like "current Height - 51dip", but the current Height is -1.

I hope you can think with me.

Best regards,
André
 
Upvote 0

AHilberink

Active Member
Licensed User
Longtime User
Hi Erel,

I tried, but non succesfull. I cann't use the TabHost.Bottom (or PanelList.Bottom), because these components are on another layoutfile.

This is my script, so far:
B4X:
ListView1.SetTopAndBottom(0,ListView1.Height - Zoeksleutel.Height)

Zoeksleutel is hidden on the start and becomes visible during the program (the ELSE part). Still the height isn't recalculated. It looks like the script is only effective on loading??

It should be simple, but I cann't get it done :-(

Hope you can help.

Best regards,
André
 
Upvote 0

AHilberink

Active Member
Licensed User
Longtime User
It is not so simple as the height is really not available.

If you want ListView1 to fill the entire tab page:
B4X:
ListView1.SetTopAndBottom(0, 100%y)
Assuming that you are loading it with TabHost.AddTab or AddTabWithIcon.

I already tried this. Not working. The ListView1 is still out of my screen. I use AddTabWithIcon.

It seems to be calculated on loading and the change of .Top doesn't effect.

Also the 100%y seems not be working on a panel inside a TabHost, because it isn't minus the height of the tab-bar. (sorry for my bad english)

Best regards,
André
 
Upvote 0

AHilberink

Active Member
Licensed User
Longtime User
Sorry but I cannot provide private technical support. You can create a simple layout just for this question.

I understand. I made a clean version, only of the problem.

I hope you can assist.

Best regards,
André
 

Attachments

  • Project.zip
    51.7 KB · Views: 155
Upvote 0

AHilberink

Active Member
Licensed User
Longtime User
You should use AddTabWithIcon not AddTabWithIcon2.

I tried this, but the bottom of ListView1 is still out of my screen.

Pressing the Search in the header, will change the ListView1.Top, but I need to change the bottom as well at that moment.

Best regards,
André
 
Upvote 0

AHilberink

Active Member
Licensed User
Longtime User
You just need to create a layout with the ListView and call ListView1.SetTopAndBottom(0, 100%y).
The ListView will fill the tab.

I tried this. The ListView1 has it's own layout. This is loaded by PanelList.

It looks like the ListView1.Height is the problem. I think the .Bottom and the SetTopAndBottom are calculated correctly on loading the layout by 100%y.

As you can see in the sourcecode, on activating the Search, I set the ListView1.Top from 0 to 51. The ListView1.Heigh should be minus 51, so it still will fit on the screen. I cannot do this, because ListView1.Height has a value of -1.

So far I cannot find a way of calculating the right Height of ListView1, because:
- The current value is -1
- I cannot get the value of ListView1.Bottom, because this is a Layout setting
- I cannot get the value of PanelList.Height, because this is also -1
- I cannot get the heigth of the TabHost ribbon (so I can calculate the position of the ListView1.Top on the screen)
- I cannot get the value of PanelList.Bottom or TabHost.Bottom because these are layout settings.

I hope this explanation will help you to understand my problem. I hoped this would be something easy, but I seems to be more than that.

Best regards,
André
 
Upvote 0

AHilberink

Active Member
Licensed User
Longtime User
Can you upload your updated project (that is based on AddTabWithIcon)?

I had to change it back, because I discover only the lastloaded tab is working with the layout file. Is there anything I am doing wrong?
 
Upvote 0
Top