Advise on Tabhost, Tables and Graphs please

nrasool

Member
Licensed User
Longtime User
Hi there, please could I have some advise. I been searching around the forums and the beginner guide

I have a tabhost which has a tableclass and line graph as diff tabs. The thing is I want to show these when you click on the button. But I don't want to change the visability, instead, I want to destory the table and line graph. The reason is that in my app you would add in different information, so when the user click on the button to view the graph, it shows an uptodate of the database.

I've read on RemoveView and RemoveAllView but this destorys everything.

Attach is just a small example of a project file which two buttons, I just want some advise on what to do on Button2_Click, so it would close or destory the line graph and table.

Please could someone help on this, or provide some advise on how they would do it.

Many thanks in advance.

Kind Regards
 

Attachments

  • TabhostTableGraph.zip
    18 KB · Views: 151

klaus

Expert
Licensed User
Longtime User
The code in for Button2 should look like this:
B4X:
Sub Button2_Click
    If TabHost1.IsInitialized Then
        TabHost1.RemoveView
    End If
End Sub
This removes the TabHost.
When you click on Button1 it will be added again.

In your example you should add the same code code in Button1_Click because if you click on Button1 before having closed with Button2 you'll get an error.
Or you should manage the Buttons to avoid it.
Yould combining both functions to the same button, like this:
B4X:
Sub Button1_Click
    If Button1.Text = "Open" Then
        Button1.Text = "Close"        
        ShowTable2
        CreateLineTab
    Else
        Button1.Text = "Open"        
        If TabHost1.IsInitialized Then
            TabHost1.RemoveView
        End If
    End If
End Sub
Best regards.
 
Upvote 0

nrasool

Member
Licensed User
Longtime User
Hi Klaus

Really appreciate you help on this, however there is an issue, as when it reappears, it adding in more tabs. So the 1st time, you just have the standard 2 tab, but when you close and reopen it, now it is 4 tab and so on. Is there a way to destory tabhost1 then when you click on the button, it creates it again

Kind Regards
 
Upvote 0

Kiese

Member
Licensed User
Longtime User
Hi all!
I was trying to code something similar and need some advice on the best approach for this.
1) I have a fixed number of tables which share the exact same structure but from different sites. The structure is say:
branch1 to branch7 (each table is a branch).
SID (primary key), Employee_ID, date-hour (ddMMyyyy-hh-mm), Employee_Dpt, Employee_Function, Employee_affectation, Employee_type
This data comes from csv files named after the tables, which should be periodically (or on demand) loaded into a database using loadcsv.

2) What I am trying to do is get this data under this format:

Tabhost1 populated with
Tab1 = day1
Number of employees of each type, by day

empltype\date day1 | day2 | day3 | day4 |...dayN
type1 |74 | 44 | etc |
type2 |22 | 32 |
type3 |44 | 29 |
...
type7 |54 | 33 |

Tab2 = branch2 (same structure)

.TabN+1 = total for all branches
(the number of days and the start date are entered by the user using 1 datedialog and an input dialog (ddial and inpdial1)
1 tab = 1 day
The data files shouldn't exceed a few hundred lines a day, to at most 10 000.

What would be the best way to do this, and avoid memory issues? All this is to be executed on a tablet with 512 MB to 1Gb RAM which doesn't seem too much, so I'am wondering if using sql queries to do the "math" and populate the cells should be the best idea here or maybe something else I am not aware of at this time.

Hope this is clear, I'm not too sure about my english, sorry...

Best regards.
 
Upvote 0

Kiese

Member
Licensed User
Longtime User
Thanks for the reply. It seems I wasn't too clear. In fact I load the csv files in sql tables first, then I want to proceed to populate the table as better explained below (I hope).
As for the data structure, it's true it wasn't really clear either, so here:
Table1 -branch1:
SID|Employee_ID|date---------------|employee_dpt|employe_function|employee_type
225|AXIIDO11223|12-08-2013-14-33|sales----------|manager----------|permanent----
Table2 -branch2:
SID|Employee_ID|date|employee_dpt|employe_function|employee|type
etc

And the one I want to load:
type--------|day1|day2|day3...|dayN
permanent-| 22..etc
transfer----| 12 etc
temporary-| 21 etc
student-----|36 etc
senior------|12 etc
associate--|15 etc

To be more specific, everytime an employee scans his/her id at the branch office, a csv file is updated with SID, employee_id etc...
What I am trying to get is the number of employees of each type for each day in each branch.

Hope that was more comprehensive this way...
 
Upvote 0

Kiese

Member
Licensed User
Longtime User
To put it more simply:
  • The system is supposed to track the movements of employees between each branch of the company through a badging system. That badging application is responsible for the csv files and the company doesn't feel like changing that. To be more specific, they find it easier to keep the old app as it is and just sync files through the cloud, instead of migrating to a database server... so I have to deal with it...even though I don't like the design...
  • Anyways, the application records each entrance of the employees in each branch day after day.
  • There are several types of employees (permanent, students, transfer etc),
  • The data that is supposed to be displayed from those files is the number of each type of employee who attended daily at each specific branch, during a given time frame.
I hope it was clearer.
Kind regards.
 
Upvote 0
Top