Android Question Tab & spacing

persianpowerman1

Active Member
Licensed User
Longtime User
Heres whats happening

i will be fetching data from a database and the output text is going to be on a big edittex box
i need to print stuff like this, in 3 columns... whose spacing i want to do with [tab]

B4X:
for i =0 to recordset-1
edittext1.text = edittext1.text & "Column1" & [tab] & "Column2" & [tab] & "Column3" & CRLF
next

example for ENTER key we use CRLF
similarly for TAB key... what may i use?

YO!han
 

LucaMs

Expert
Licensed User
Longtime User


For tab you can use... Tab

But the columns may not always be aligned. It depends on the content of each field.
You shuld use both CRLF and TAB, but use spaces (" ") added on the left or right to each field.
In VB.Net there are functions like Rset and Lset (or they was in vb6? ).
You shoud create those functions (ehm maybe there is something like those in StringFunctions or StringUtils libraries).

I found something in StringFunctions: AddSpaces.

B4X:
Sub Globals
    Dim mStrFunc As StringFunctions
End Sub

B4X:
Sub Rset(Text As String, MaxWidth As Int) As String
    Dim Res As String

    If Text.Length >= MaxWidth Then
        ' Attention: it could truncate your Text
        Res = Text.SubString2(0, MaxWidth-1)
    Else
        Res = mStrFunc.AddSpaces(MaxWidth - Text.Length) & Text
    End If

    Return Res
End Sub

LSet would be analogous.

B4X:
for i =0 to recordset-1
edittext1.text = edittext1.text & RSet("Column1", 12) & TAB _
                                & Rset("Column2", 12) & TAB _
                                & Rset("Column3", 15) & CRLF
next

(Obviously, the content of the columns).

As usual, I have not done tests. Try it.
 
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User


This is infinitely better (you can see here that I was sleeping).

Also, instead of using functions like Rset or LSet, you can use a not visible label, with its Gravity, for the alignment
 
Upvote 0

persianpowerman1

Active Member
Licensed User
Longtime User
thanx...
yeah guys... i did try it out... it seems to be much better than my concept of an EDITText with TAB and space and CRLF....
how ever is it efficient...as it gives me delayed responses???

ALSO, in SQLiteLight2 example by KLAUS... i use his brilliant WebView Table...

so do you guys recomend this Table class over the ... WebView Table in KLAUS example... what say?

YO!han
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Personally, I can not advise you, because I used a bizarre system in my app (because I did not know enough B4A).
I used the Types (I had no Classes in B4A 1.80) and the sample taken from the scrollview Beginners Guide,
so do not know well those two classes.

The ideal would be to create an editable binding DataGridView as in VB.Net (complicated but not impossible, at least similar).
It seems to me also that I have seen editable grids, here on the site (perhaps that of Klaus?)

So I suggest you ... to wait for further advice


P.S. Flexible Class (by Klaus) can be very useful.
I have not read that it allows editing, but saves in CVS, so maybe it does; however it is a class, so you can adapt it to your needs.
(thinking... in CVS you can't save images-BLOB)
 
Last edited:
Upvote 0

persianpowerman1

Active Member
Licensed User
Longtime User
hey thanx guys ...

KLAUS... the only reason i am still not considering Table class cz it kinda executed slow... like with a pause... especially in Debug mode... as if a lag existed...
or it may be on just my emulator... ?

So ... since you've used both.. do u find any lag in the Table class? like getting stuck?... cz if not.. i'll incorporate that in the remaining part of my coding

YO!han
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
AVD emulators are slow!

It also depends on how many records you get and if the query works on many tables and indexes.

I repeat that I do not know those two classes, but I do not think there can be much difference in terms of speed between them.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
KLAUS... the only reason i am still not considering Table class cz it kinda executed slow... like with a pause... especially in Debug mode... as if a lag existed
How, or with what program did you test the Table class ?
As Luca already asked, how many records did the Table have ?
 
Upvote 0

persianpowerman1

Active Member
Licensed User
Longtime User
ok... good question...
im talking 30 records... and the same AVD i used for both...
ALso... the WebView table actually connected to a DB.... and the Table Class only filled rows up via a loop..

webView table never ever got stuck in Debug mode... but table class did/does

hence i thought there might be some other processing happening in the background thats slowing the table class down?!
 
Upvote 0

CyclopDroid

Well-Known Member
Licensed User
Longtime User
Dopo 4 giorni con internet fuori uso eccomi a richiedere aiutini
Ho bisogno di un qualcosa di simile, per una label.

Passo 2 valori e vorrei che fossero allineati ma, utilizzando la Sub Rset del buon Luca, non funziona... si spostano comunque.

B4X:
Rix.Text=Rix.Text & TAB & Rset(Punti,80)

Questo è il risultato


 
Upvote 0

CyclopDroid

Well-Known Member
Licensed User
Longtime User

Nothing.
I've try with Rix.Gravity=Gravity.Right and with SV.SingleLineLayout.Label.Gravity=Gravity.Right (SV is a ListView Object).
The resoult it's some image Up.
... the Rix label have two label :

Rix.Text=Rix.Text & TAB & Rset(Punti.Text,80)

mmmh, with this method (listlview) with two label and Rset, I have a problem with other device(Tablet 7", 10",etc.).
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
"Parole trovate" e Punti are a unique label?

If so, you could use two listviews.

Also, maybe you should use a monospaced font

(as you know, you can send me the source code - or part of it, I will publish never my app, but yours...! )


[two listviews is a stupid suggestion: how to scroll them synchronously??? Sorry]
 
Last edited:
Upvote 0

CyclopDroid

Well-Known Member
Licensed User
Longtime User
I have try to insert a gravity into second label:


B4X:
    PuntiS.Gravity=Gravity.RIGHT
    Rix.Text=Rix.Text & TAB & Rset(PuntiS.TEXT,70)
    SV.AddSingleLine(Rix.Text)

...but the result not change.

What is an monospace fonts? Currier New is monispace but exist in Windows 8?
When i change the font?
It's not possible syncronize two listview?...your idea would not be bad.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
You should take a look to ListView in the documentation

AddSingleLine adds... a single line in the single "layout" of the listview. You don't need this, in the TwoLines layout the label are one above the other.

Monospace fonts are font in which each letter have same width. You can use this code or you can select TextStyle - TypeFace - Monospace in the designer or:
MyListView.SingleLineLayout.Label.Typeface = Typeface.MONOSPACE
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…