Android Question Table+panels

Discussion in 'Android Questions' started by Pilar-JLSineriz, Jun 18, 2015.

  1. Pilar-JLSineriz

    Pilar-JLSineriz Active Member Licensed User

    Dear alls,
    Using the table class example, I've used the designer to create the panel, named as in the example, "pnlTable". The layout name is screen6_pasivominero. I don´t get to charge the table in the panel. if I use tha table class example, with my BD and SQL, I don´t have problem. The problem appears if I want to use the designer to create the panel. Could you help me?? Regards

    Sub Globals
    Dim Table1 As Table
    Dim pnlTable As Panel
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("screen6_pasivominero")
    pnlTable.Initialize("pnlTable")
    Table1.Initialize(Me, "Table1", 5, Gravity.CENTER_HORIZONTAL, True)

    Table1.CellAlignment = Bit.Or(Gravity.LEFT, Gravity.CENTER_VERTICAL)
    Table1.RowHeight = 40dip
    Table1.AddToActivity(pnlTable, 0, 50%y, pnlTable.Width, pnlTable.Height)
    Table1.MultiSelect = False
    Table1.SortColumn = False
    Table1.SingleLine = False
    FillTableSQLite
    End Sub

    Sub FillTableSQLite
    Dim Query As String

    Table1.ClearAll

    Table1.LineWidth = 3dip

    Table1.TextSize = 18

    Dim tf() As Typeface
    tf = Array As Typeface(Typeface.DEFAULT, Typeface.DEFAULT, Typeface.DEFAULT, Typeface.DEFAULT, Typeface.DEFAULT)
    Table1.SetTypeFaces(tf)

    Table1.UseColumnColors = True
    Query = "SELECT Codigo As [ID], Nombre As [Denominación] , Naturaleza, Distancia As [Distancia (m)], Uso As [Usos del Agua] FROM AguaSuperficial" Table1.LoadSQLiteDB(Main.s, Query, True)End Sub
     
  2. klaus

    klaus Expert Licensed User

    You must remove this line !
    pnlTable.Initialize("pnlTable")
    Because pnlTable is defined in the Designer !

    What version of the Table Class do you use ?
    Do you really need the Panel ?
    The Table Class includes already a Panel to hold all its internal views.
     
  3. Pilar-JLSineriz

    Pilar-JLSineriz Active Member Licensed User

    Hi Klaus,

    I removed the line and I have the same problem.
    Only I use the panel to fix the design in the view. it's easier for me that to use % or dip.
    I am using Version 1.43.

    Thanks
     
  4. Pilar-JLSineriz

    Pilar-JLSineriz Active Member Licensed User

    HI Klaus, I got it without panel, only with the table.. thanks
     
  5. Pilar-JLSineriz

    Pilar-JLSineriz Active Member Licensed User

    Hi again,

    How can I get to limit the width of the table (table-class)? I've observed that the size is increased in function of the content of the second column, and a piece of my table disappears.. thanks
     
  6. klaus

    klaus Expert Licensed User

    When you add the Table class to the Activity.
    Table1.AddToActivity(Activiy, 0, 50%y, YourWidth, YourHeight)
    Or you can still have the pnlTable Panel to use the dimensions
    Table1.AddToActivity(Activiy, 0, 50%y, pnlTable.Width, pnlTable.Height)
    and remove pnlTable with pnlTable.RemoveView.
     
  7. Pilar-JLSineriz

    Pilar-JLSineriz Active Member Licensed User

    A good idea!!! I've used;

    Table1.AddToActivity(Activity,pnlTable.Left,pnlTable.top, pnlTable.Width, pnlTable.Height)
    pnlTable.RemoveView

    How could I control the column size? I use Table1.SetColumnsWidths(Array As Int(60dip, 40dip, 30dip, 30dip, 100%x - 160dip)) (5 columns), but I have an error; java.lang.RuntimeException: Object should first be initialized (View).

    My brother died the last monday
     
  8. Pilar-JLSineriz

    Pilar-JLSineriz Active Member Licensed User

    Klaus, it's fantastic the use of "table"!!!!!!!!!!!!! :);)
     
  9. klaus

    klaus Expert Licensed User

    My sincere condolences.

    From your last post I suppose that it works.

    The sum of the column widths must not be equal to the Table width.
    If the sum of the column widths is bigger than the Table width the Table scrolls horizontally.
    As you are using Table1.LoadSQLiteDB(Main.s, Query, True) the widths are calculated automatically according to the widest entry.
    If you don't want the automatic widths you should use Table1.LoadSQLiteDB(Main.s, Query, False) avoiding the width calculations.
     
    Erel likes this.
  10. Pilar-JLSineriz

    Pilar-JLSineriz Active Member Licensed User

    Thanks Klaus for your condelences.
    When I wrote you I had not seen the property true and false (Table1.LoadSQLiteDB).. and when you replied me, I had solved. In any case, thanks.. these days are being very difficult to me

    Now I have other problem;

    I have a DB, "PasivosMineros.sqlite" without data. I want to copy its structure in a new DB. When I begin the application, I give name to the new DB, in function of one paremeter, in this case, DBFileName is "PasivosMineros_02.sqlite"

    If newCampaña=True Then
    DBFileName="PasivosMineros_" & txtTABLET.Text & ".sqlite"
    Log(DBFileName) ''"PasivosMineros_02.sqlite"
    If File.Exists(File.DirDefaultExternal,"PasivosMineros.sqlite") =False Then
    DBFileDir=DBUtils.CopyDBFromAssets("PasivosMineros.sqlite")
    File.Copy(File.DirAssets, "PasivosMineros.sqlite", File.DirInternal, DBFileName)
    End If

    end if

    The error indicates that not found "PasivosMineros.sqlite" and this DB is in the folder. Of course, "PasivosMineros_02.sqlite" is not create.

    Best regards :(
     
  11. klaus

    klaus Expert Licensed User

    You should post more code.
    Where do you get the error ?
     
  12. Pilar-JLSineriz

    Pilar-JLSineriz Active Member Licensed User

    I don´t have more code
    the error is the following
    java.io.FileNotFoundException: pasivosmineros.sqlite
     
  13. Pilar-JLSineriz

    Pilar-JLSineriz Active Member Licensed User

    Hi Klaus

    I solved the error.. I had not copied the pasivosmineros.sqlite in the folder!!!!! (in B4A).. but I don´t get to copy the file and create "PasivosMineros_02.sqlite"

    If newCampaña=True Then 'Nueva campaña
    DBFileName="PasivosMineros_" & txtTABLET.Text & ".sqlite" 'Nombro el fichero en función del número de tablet
    Log(DBFileName)
    If File.Exists(File.DirDefaultExternal,"PasivosMineros.sqlite") =False Then
    DBFileDir=DBUtils.CopyDBFromAssets("PasivosMineros.sqlite")
    File.Copy(File.DirDefaultExternal, "PasivosMineros.sqlite", File.DirInternal, DBFileName)
    End If
    end if
     
  14. Pilar-JLSineriz

    Pilar-JLSineriz Active Member Licensed User

    I get it!!!!!!!!! ;)

    DBFileName="PasivosMineros_" & txtTABLET.Text & ".sqlite" 'Nombro el fichero en función del número de tablet

    If File.Exists(File.DirDefaultExternal,"PasivosMineros.sqlite") =False Then
    File.Copy(File.DirAssets, "PasivosMineros.sqlite",File.DirDefaultExternal, "PasivosMineros.sqlite")
    File.Copy(File.DirDefaultExternal, "PasivosMineros.sqlite", File.DirDefaultExternal, DBFileName)
    s.Initialize(File.DirDefaultExternal, DBFileName, True)

    End If
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice