German IME macht probleme

Sinan Tuzcu

Well-Known Member
Licensed User
Longtime User
Hallo,

ich habe dieses bei mir im Projekt eingebaut und es gibt nur Probleme damit.
Code aus dem Tutorial:
B4X:
Sub Process_Globals

End Sub
Sub Globals   
   Dim IME As IME
   Dim EditText1 As EditText
   Dim btnHideKeyboard As Button
   Dim EditText2 As EditText
   Dim EditText3 As EditText
   Dim EditText4 As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("1")
   IME.Initialize("IME")
   IME.AddHeightChangedEvent
   IME_HeightChanged(100%y, 0) 'manually call this method to set the layout of EditText1 and btnHideKeyboard
   IME.AddHandleActionEvent(EditText2)
   IME.SetCustomFilter(EditText3, EditText3.INPUT_TYPE_NUMBERS, "0123456789.")
   IME.SetCustomFilter(EditText4, Bit.OR(EditText4.INPUT_TYPE_TEXT, 0x00080000), _ '0x0080000 is the flag of NO_SUGGESTIONS.
      "01234567890abcdef")
End Sub

Sub IME_HandleAction As Boolean
   Dim e As EditText
   e = Sender
   If e.Text.StartsWith("a") = False Then
      ToastMessageShow("Text must start with 'a'.", True)
      'Consume the event.
      'The keyboard will not be closed
      Return True
   Else
      Return False 'will close the keyboard
   End If 
End Sub

Sub IME_HeightChanged(NewHeight As Int, OldHeight As Int)
   btnHideKeyboard.Top = NewHeight - btnHideKeyboard.Height
   EditText1.Height = btnHideKeyboard.Top - EditText1.Top
End Sub

Sub Activity_Pause(UserClosed As Boolean)

End Sub
Sub btnShowKeyboard_Click
   'IME.ShowKeyboard(EditText2)
End Sub
Sub btnHideKeyboard_Click
   'IME.HideKeyboard
End Sub

Eingebaut habe ich das in ein Activity, wo sich nur Zwei Textfelder und ein Button befindet.
Das Problem ist, das der Button solange eingefroren ist, bis die Tastatur verschwindet.

Ich kann mir nicht erklären woran das liegt. Hatte schon mal einer von euch den selben fehler?

Hier der Code bei mir in Activity
B4X:
Sub Process_Globals

End Sub

Sub Globals
Dim IME As IME
   
   Dim EditText1 As EditText
   Dim Button1 As Button
   Dim EditText2 As EditText
   Dim phone1 As Phone

End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("haberyolla")
            
   phone1.SetScreenOrientation(-1)
   
   IME.Initialize("IME")
   IME.AddHeightChangedEvent
   IME_HeightChanged(100%y, 0) 
   StartService(OneSMS)

End Sub

Sub IME_HeightChanged(NewHeight As Int, OldHeight As Int)
   EditText2.Top = NewHeight - EditText2.Height
   Button1.Top = EditText2.Top
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event

 If KeyCode = KeyCodes.KEYCODE_BACK Then
   Activity.Finish
   StartActivity("Obstliste")
 End If

End Sub

Sub Button1_Click
Dim textnull As String
Dim link As String
Dim BName As String

If EditText1.Text="" Then 
Msgbox("Bitte gib eine Kategorie ein.","")
Return
End If


textnull = codlar.Left(EditText1.text,2)
For k = 1 To textnull.Length -1
If codlar.MidLengh(textnull, k, 1) = "G" OR textnull = "GB" Then
BName = su.EncodeUrl(Benutzername, "UTF8")
OneSMS.kime = codlar.mid(EditText1.text,2)
CallSubDelayed(OneSMS, "ciftsifir")
Return
End If

IME.HideKeyboard
Activity.Finish
StartActivity("Obstliste")

End Sub
 
Last edited:

Sinan Tuzcu

Well-Known Member
Licensed User
Longtime User
Problem gelöst...

eine Frage hätte ich noch dazu.

Wie kann ich das so regeln, das der TextBox sich in die Höhe mit vergrößert, wenn der Text mehr Zeilig wird?

gruß
sinan
 

Sinan Tuzcu

Well-Known Member
Licensed User
Longtime User
Hi Klaus,

gibt es denn da auch so ne kleine Ansatz, wie man das macht?

Dim Label1 As Label
Label1.Initialize("")
Label1.Text = "this is a long sentence, and we need to " _
& "know the height required in order To show it completely."
Label1.TextSize = 20
Activity.AddView(Label1, 10dip, 10dip, 200dip, 30dip)
Dim su As StringUtils
Label1.Height = su.MeasureMultilineTextHeight(Label1, Label1.Text)


damit geht es nicht
 

klaus

Expert
Licensed User
Longtime User
Was meinst Du mit damit geht es nicht ?
Der Code den Du gepostet hast funktioniert einwandfrei !

Es funktioniert auch mit EditText Views !
B4X:
Sub Globals
    Dim EditText1 As EditText
    Dim su As StringUtils
End Sub

Sub Activity_Create(FirstTime As Boolean)
    EditText1.Initialize("EditText1")
    Activity.AddView(EditText1, 10dip, 10dip, 250dip, 30dip)
    EditText1.TextSize = 20
    EditText1.Text = "this is a long sentence, and we need to " _
    & "know the height required in order To show it completely."
    EditText1.Color = Colors.Red
    EditText1.TextColor = Colors.White
    EditText1.SingleLine = False
End Sub

Sub EditText1_TextChanged (Old As String, New As String)
    EditText1.Height = su.MeasureMultilineTextHeight(EditText1, New) + 15dip
End Sub
Beste Grüsse.
 

Sinan Tuzcu

Well-Known Member
Licensed User
Longtime User
Hi Klaus,

wenn ich aber dein Code hier einbaue

B4X:
Sub Process_Globals

End Sub
Sub Globals   
    Dim IME As IME
    Dim EditText1 As EditText
    Dim btnHideKeyboard As Button
    Dim EditText2 As EditText
    Dim EditText3 As EditText
    Dim EditText4 As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    IME.Initialize("IME")
    IME.AddHeightChangedEvent
    IME_HeightChanged(100%y, 0) 'manually call this method to set the layout of EditText1 and btnHideKeyboard
    IME.AddHandleActionEvent(EditText2)
    IME.SetCustomFilter(EditText3, EditText3.INPUT_TYPE_NUMBERS, "0123456789.")
    IME.SetCustomFilter(EditText4, Bit.OR(EditText4.INPUT_TYPE_TEXT, 0x00080000), _ '0x0080000 is the flag of NO_SUGGESTIONS.
        "01234567890abcdef")
End Sub

Sub IME_HandleAction As Boolean
    Dim e As EditText
    e = Sender
    If e.Text.StartsWith("a") = False Then
        ToastMessageShow("Text must start with 'a'.", True)
        'Consume the event.
        'The keyboard will not be closed
        Return True
    Else
        Return False 'will close the keyboard
    End If 
End Sub

Sub IME_HeightChanged(NewHeight As Int, OldHeight As Int)
    btnHideKeyboard.Top = NewHeight - btnHideKeyboard.Height
   Dim su As StringUtils
   EditText1.Height = su.MeasureMultilineTextHeight(EditText1, NewHeight) + 15dip
    'EditText1.Height = btnHideKeyboard.Top - EditText1.Top
End Sub

Sub Activity_Pause(UserClosed As Boolean)

End Sub
Sub btnShowKeyboard_Click
    'IME.ShowKeyboard(EditText2)
End Sub
Sub btnHideKeyboard_Click
    'IME.HideKeyboard
End Sub

dann funktioniert es nicht ... warum auch immer

gruß
sinan
 
Last edited:

klaus

Expert
Licensed User
Longtime User
Du hast den Code aber falsch eingebaut.
Wo ist dieser Code ?
B4X:
Sub EditText1_TextChanged (Old As String, New As String)
    EditText1.Height = su.MeasureMultilineTextHeight(EditText1, New) + 15dip
End Sub
Warum hast Du
EditText1.Height = su.MeasureMultilineTextHeight(EditText1, New) + 15dip
in die IME_HeightChanged Routine eingebaut.

Beste Grüsse.
 
Top