hi, I have several texview on my program , some are located in the upper delloo screen while others are located at the bottom. My problem comes when I write such a TextView up and then I would write in a TextView down, I can not see it because of the keyboard visible , how do I prevent the keyboard hide me the texview located under the keyboard not allowing me to write to them ?
This should move the Root panel enough so the focused view is visible. The next question is how to move from one text field to the next. A quick search seems to imply that it is up to the programmer to manage that, unless anyone has found a solution already. I have run out of time today, if you don't get a solution, I may be able to have a look tomorrow.
B4X:
Sub Page1_KeyboardStateChanged (Height As Float)
If Height = 0 Then
Page1.RootPanel.Top = 0
Else
For Each V As View In Page1.RootPanel.GetAllViewsRecursive
If IsFirstResponder(V) Then Page1.RootPanel.Top = Min(0,Page1.RootPanel.Top - (Height - (Page1.RootPanel.Height - (V.Top + V.Height))))
Next
End If
End Sub
Sub IsFirstResponder(V As NativeObject) As Boolean
If V.RunMethod("isFirstResponder",Null) = 1 Then Return True
Return False
End Sub
I am tending to build my screens on a scrollview so that it is easy for the user to see what they want with the keyboard up. The problem I found was that when the keyboard is up, the toolbar is hidden. After fiddling around and reading the various suggestions, I discovered that in the click event of a page or scrollview I choose any existing text field (no added buttons etc) and:
B4X:
Sub svContFields_click
edtName.RequestFocus
edtName.ResignFocus
End Sub
I found that to resignfocus only did not work. So in my case, all the user has to do is tap the screen to get rid of the keyboard.
This should move the Root panel enough so the focused view is visible. The next question is how to move from one text field to the next. A quick search seems to imply that it is up to the programmer to manage that, unless anyone has found a solution already. I have run out of time today, if you don't get a solution, I may be able to have a look tomorrow.
B4X:
Sub Page1_KeyboardStateChanged (Height As Float)
If Height = 0 Then
Page1.RootPanel.Top = 0
Else
For Each V As View In Page1.RootPanel.GetAllViewsRecursive
If IsFirstResponder(V) Then Page1.RootPanel.Top = Min(0,Page1.RootPanel.Top - (Height - (Page1.RootPanel.Height - (V.Top + V.Height))))
Next
End If
End Sub
Sub IsFirstResponder(V As NativeObject) As Boolean
If V.RunMethod("isFirstResponder",Null) = 1 Then Return True
Return False
End Sub
This code is giving type do not match now but it was working perfect some time ago. Is there nay way to fix it ?
( it givs the error on :
If V.RunMethod("isFirstResponder",Null) = 1ThenReturnTrue )
This code is giving type do not match now but it was working perfect some time ago. Is there nay way to fix it ?
( it givs the error on :
If V.RunMethod("isFirstResponder",Null) = 1ThenReturnTrue )
Sub pg_KeyboardStateChanged (Height As Float)
'输入法不挡住输入框
If Height = 0 Then
pg.RootPanel.Top = 0
Else
For Each V As View In pg.RootPanel.GetAllViewsRecursive
If IsFirstResponder(V) Then pg.RootPanel.Top = Min(0,0 - (Height - (pg.RootPanel.Height - (V.Top + V.Height+50dip))))
Next
End If
End Sub
'判断是否为第一响应者
Sub IsFirstResponder(V As NativeObject) As Boolean
Return V.RunMethod("isFirstResponder",Null).AsBoolean
End Sub
This should move the Root panel enough so the focused view is visible. The next question is how to move from one text field to the next. A quick search seems to imply that it is up to the programmer to manage that, unless anyone has found a solution already. I have run out of time today, if you don't get a solution, I may be able to have a look tomorrow.
B4X:
Sub Page1_KeyboardStateChanged (Height As Float)
If Height = 0 Then
Page1.RootPanel.Top = 0
Else
For Each V As View In Page1.RootPanel.GetAllViewsRecursive
If IsFirstResponder(V) Then Page1.RootPanel.Top = Min(0,Page1.RootPanel.Top - (Height - (Page1.RootPanel.Height - (V.Top + V.Height))))
Next
End If
End Sub
Sub IsFirstResponder(V As NativeObject) As Boolean
If V.RunMethod("isFirstResponder",Null) = 1 Then Return True
Return False
End Sub