Spanish [SOLUCIONADO] Iconos en toolbar

RAFA BRAVO

Active Member
Licensed User
Longtime User
Utilizo la instrucción B4XPages.SetTitle(Me, Chr(0xF007) pero no es posible representar material icons. alguien sabe si es posible hacer esto?
 

roerGarcia

Active Member
Licensed User
Longtime User
Prueba esto

You can also use the icons in your code.
- Right click in the code editor and choose Icon Picker.
- Click on an icon to copy it to the clipboard.
- Paste it in your code. It will look like:
B4X:

Button1.Text = Chr(0xF17B)
Make sure that the control's font is set to the correct font.
 

angel_

Well-Known Member
Licensed User
Longtime User
Prueba así:

B4X:
    Dim Titulo As CSBuilder
    
    Titulo.Initialize
    Titulo.Typeface(Typeface.FONTAWESOME).Append(Chr(0xF007)).PopAll
    
    B4XPages.SetTitle(Me, Titulo)
 

RAFA BRAVO

Active Member
Licensed User
Longtime User
No logro que aparezca el icono, solo aparece un cuadrado con una x dentro.
 

RAFA BRAVO

Active Member
Licensed User
Longtime User
me gustaria poder poner iconos y letras tanto en la barra de herramientas como en el menu desplegable, pero solo logro representar el texto
 

musaso

Active Member
Licensed User
Prueba con esto
B4X:
Public Sub TextToBitmap (s As String, IsMaterialIcons As Boolean, FontSize As Float, color As Int) As Bitmap
    Dim bmp As Bitmap
    bmp.InitializeMutable(32dip, 32dip)
    Dim cvs As Canvas
    cvs.Initialize2(bmp)
    Dim h As Double
    Dim t As Typeface
    If IsMaterialIcons Then t = Typeface.MATERIALICONS Else t = Typeface.FONTAWESOME
    h = cvs.MeasureStringHeight(s, t, FontSize)
    cvs.DrawText(s, bmp.Width / 2, bmp.Height / 2 + h / 2, t, FontSize, color, "CENTER")
    Return bmp
End Sub

Ejemplo :

B4X:
    Dim bd As BitmapDrawable
    bd.Initialize(TextToBitmap(Chr(0xF2BA),False, 26,Colors.Red))
 

RAFA BRAVO

Active Member
Licensed User
Longtime User
Lo he probado y funciona sin problema, sube un ejemplo
Si , perdón, cambie esto: (Typeface.FONTAWESOME) por (Typeface.MATERIALICONS) y por eso no funcionaba, no se por que pensé que era materialicons.

Omar utilizando tu ejemplo, lo combine así para representarlo como deseo:

B4X:
Sub GetSelectedRecord (inicioSesion As String)
'    EN ESTA RUTINA MUESTRO TODOS LOS DATOS SUBIDOS A MYSQL Y QUIERO MOSTRAR TAMBIEN EN IMAGEVIEW LA IMAGEN SELECCIONADA
    Dim req As DBRequestManager = CreateRequest
    Dim cmd As DBCommand = CreateCommand("selectedSesionON", Array(inicioSesion))
    Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
    ProgressDialogShow("Cargando...")
    If j.Success Then
        req.HandleJobAsync(j, "req")
        Wait For (req) req_Result(res As DBResult)
        'work with result
        req.PrintTable(res)
'        Log(res.Columns)
        For Each row() As Object In res.Rows
            
            NombreYapellido  = ("   " & row(1) & " " & row(2))
            Dim Titulo As CSBuilder
            Titulo.Initialize
            Titulo.Typeface(Typeface.MATERIALICONS).Append(Chr(0xF007)).PopAll
            Titulo.Append(NombreYapellido)
            B4XPages.SetTitle(Me, Titulo)
            
        Next
    Else
        Log("ERROR: " & j.ErrorMessage)
    End If
    ProgressDialogHide
    j.Release
End Sub

La parte de texto que quiero representar son el nombre y apellido que obtengo de una base de datos y queda así por si a alguien le interesa:


Screenshot_b4a.FordToolGlass.jpg


Tengo otra pregunta, pero como esta a quedado resuelta lo hare en un hilo nuevo, gracias a todos, un saludo.
 
Top