Hide listview on android

Discuss GUI programming with the RapaGUI plugin here
Post Reply
amyren
Posts: 422
Joined: Thu May 02, 2019 11:53 am

Hide listview on android

Post by amyren »

I have this program that i similar to the Dialogs example just that I have two list (lv and lv2) and more buttons.
It is set up so there is a button row on top, then a title label, and the first listview
Below there another button row, a new titlelabel and then the second listview. At the bottom the third row of buttons.
This works well on Desktop systems like windows or MorpOS, but on Android the content gets quite cramped so I can hardly see the content of the lists due to the space the buttons and the labels. It helps to minimize zoom on android, but its a bit cumbersome to have to do this every time.

To adress this I added some menu options to hide any of these objects using eg. moai.Set("lv", "hide", 1)
This worked on Windows.
But on Android it works differently.
First thing I found is that although its does hide lists content it does not hide the column titles of the lists.
To work around this I added moai.set lines to hide each of these columns, so now that is taken care of.

Now I can hide the buttons, labels and the lists, and I can show just one of the lists on screen at the time. On windows the list content will now expand to fill the window so I can see many entries at once.
On Android this does not happen. The upper list will be restricted to the upper part of the screen even if the bottom is just empty space, and same for the second list that will be limited to a small lower part of the screen.

Is there anything I can do to make any of the lists use the available space on android as well?

Secondly, are these observations considered as bugs?
plouf
Posts: 680
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: Hide listview on android

Post by plouf »

i lost it :)

but if i understand correctly i will use Pageview , to create classic "tab style" panels like firefox etc
this is the most widely used method to organize thinks

if you provide and any example of "android not working good" to see :)
Christos
amyren
Posts: 422
Joined: Thu May 02, 2019 11:53 am

Re: Hide listview on android

Post by amyren »

Ok, I made this smaller example, based the Dialogs example from the docs.
There are menu entries to hide the lower lv2 list as well as hiding the buttons. Another menu entry to show them again.
Put the files in the same folder and run the script from your desktop first to see how it looks.

Then compile ut as an applet and run it with the android Hollywwod Player, then quit.
After running it once the Dialogs folder will be created by the Hollywood Player. Copy the adressbook.dat into the Dialogs folder and run the applet again to load the content of the dat file.

Now you should see what happens when just hiding the lv2 list and buttons, and how the lv list content is shown only on the upper part of the display.

Hollywood script

Code: Select all

@REQUIRE "RapaGUI"

@FILE 1, "Dialogs.xml"

Function p_CloseDialog()
	moai.DoMethod("dlg", "endmodal", 0)	
EndFunction

Function p_EventFunc(msg)
	Switch msg.action
	Case "RapaGUI":
		Switch msg.attribute
		Case "Active":
			p_RefreshButtons(msg.triggervalue)
		Case "Selected":
			Switch msg.id
			Case "mn_list_hide":
				moai.Set("lv2", "hide", 1)
				moai.Set("testbutton", "hide", 1)
				moai.Set("testbutton2", "hide", 1)
			Case "mn_list_hide_cols":
				moai.Set("lv2col0", "hide", 1)
				moai.Set("lv2col1", "hide", 1)
				moai.Set("lv2col2", "hide", 1)
				moai.Set("lv2col3", "hide", 1)
				moai.Set("lv2col4", "hide", 1)
				moai.Set("lv2col5", "hide", 1)
				moai.Set("lv2col6", "hide", 1)
			Case "mn_list_show":
				moai.Set("lv2", "hide", 0)
				moai.Set("testbutton", "hide", 0)
				moai.Set("testbutton2", "hide", 0)
				moai.Set("lv2col0", "hide", 0)
				moai.Set("lv2col1", "hide", 0)
				moai.Set("lv2col2", "hide", 0)
				moai.Set("lv2col3", "hide", 0)
				moai.Set("lv2col4", "hide", 0)
				moai.Set("lv2col5", "hide", 0)
				moai.Set("lv2col6", "hide", 0)
			Case "mn_exit":
				End
			EndSwitch		
		Case "Pressed":
			Switch msg.id
			Case "testbutton"
				DebugPrint("TB")
			EndSwitch																			
		EndSwitch
	EndSwitch	
EndFunction

Function p_load()
	adressbook = CreateList()
	If Exists("adressbook.dat")
		moai.DoMethod("lv", "clear")
		OpenFile(1, "adressbook.dat", #MODE_READ)
			adressbook = ReadTable(1, {Adapter = "default"})
		CloseFile(1)
		For i = 0 To ListItems(adressbook)-1
			state = adressbook[i][0]
			lastname$ = adressbook[i][1]
			firstname$ = adressbook[i][2]
			street$ = adressbook[i][3]
			city$ = adressbook[i][4]
			zip$ = adressbook[i][5]
			country$ = adressbook[i][6]
		moai.DoMethod("lv", "insert", "bottom", state, lastname$, firstname$, street$, city$, zip$, country$)
		Next
	EndIf
EndFunction

Function p_OpenDialog()
	moai.DoMethod("dlg", "showmodal")	
EndFunction

Function p_RefreshButtons(active)
	moai.Set("rem", "disabled", active = -1)
	moai.Set("edit", "disabled", active = -1)			
	moai.Set("mvup", "disabled", (active <= 0))
	moai.Set("mvdown", "disabled", (active = -1) Or (active = moai.Get("lv", "entries") - 1))	
EndFunction
	
Function p_ShowHideDialog(dlg$, flag)
	If flag
		moai.Set("app", "sleep", True)
		moai.Set(dlg$, "open", True)
	Else
		moai.Set(dlg$, "open", False)
		moai.FreeDialog(dlg$)	
		moai.Set("app", "sleep", False)	
	EndIf
EndFunction

moai.CreateApp(ReadString(1))

InstallEventHandler({RapaGUI = p_EventFunc})

p_load

Repeat
	WaitEvent
Forever
Dialogs.xml

Code: Select all

<?xml version="1.0" encoding="iso-8859-1"?>
<application id="app">
	
	<menubar id="menubar">
		
		<menu title="_File">
			<item id="mn_list_hide">Hide lower list and buttons</item>
			<item id="mn_list_hide_cols">Hide lower list columns</item>
			<item id="mn_list_show">Show lower list and button</item>
			<item/>
			<item id="mn_exit" type="quit">E_xit</item>
		</menu>		
	</menubar>
					
	<window id="win" title="Dialogs" width="800" height="600" menubar="menubar" singlemenu="true">
		<vgroup>
			<label id="Main_list" align="center" tooltip="Adresses">Adress list </label>
			<listview id="lv" notify="active">
				<column title="Select" checkbox="true"/>
				<column title="Last name" editable="true"/>
				<column title="First name" editable="true"/>
				<column title="Street" editable="true"/>
				<column title="City" editable="true"/>
				<column title="ZIP" editable="true"/>								
				<column title="Country" editable="true"/>
			</listview>
			
			<hgroup>
				<button id="testbutton">Test</button>
			</hgroup>		
			<listview id="lv2" notify="active">
				<column id="lv2col0" title="Select2" checkbox="true"/>
				<column id="lv2col1" title="Last name2" editable="true"/>
				<column id="lv2col2" title="First name2" editable="true"/>
				<column id="lv2col3" title="Street2" editable="true"/>
				<column id="lv2col4" title="City2" editable="true"/>
				<column id="lv2col5" title="ZIP2" editable="true"/>								
				<column id="lv2col6" title="Country2" editable="true"/>
			</listview>
			
			<hgroup>
				<button id="testbutton2">Test2</button>
			</hgroup>				
		</vgroup>
	</window>		
</application>
adressbook.dat

Code: Select all

[
	[
		"0",
		"Johnson",
		"John",
		"Longlongroad 9876",
		"Burpinton",
		"88228",
		"New Bulgaria"
	],
	[
		"0",
		"Tosh",
		"Gordon",
		"Starling alley 42379",
		"Loonytown",
		"234566",
		"New zeeland"
	],
	[
		"0",
		"Peterson",
		"Abraham",
		"Crossing 123",
		"Hopton",
		"12344",
		"Nothere"
	],
	[
		"0",
		"Pan",
		"Peter",
		"Sterling silver 905",
		"Silverstar",
		"101010",
		"Neverland"
	],
	[
		"0",
		"Duck",
		"Donald",
		"Milkyway 313",
		"Ducktown",
		"883399",
		"Disneyland"
	],
	[
		"0",
		"Roger",
		"Jolly",
		"Piratestreet 41",
		"Bandittown",
		"65432",
		"Wasteland"
	],
	[
		"0",
		"Girl",
		"Daddys",
		"Uphill 41",
		"Downtown",
		"213141",
		"Fatherland"
	],
	[
		"0",
		"Boy",
		"Mummys",
		"Nevermove 88",
		"Hometown",
		"112233",
		"Motherland"
	]
]
Post Reply