Android Question How to change edittext color when softkeyboard pops up=

Andrew4Good

Member
Licensed User
Longtime User
Hello,

I´m doing a try-out of B4A and am quite surprised about it's functionality.

I'm very interested in de SQLite options.

Trying out the SQLExample, I wanted to change the Cell labels by edittexts, so one could edit in the cells without changing to another edit screen.

This can be done without problems, and i've done so

But when selecting one of these edittext fields, the soft-keyboard pops up and at that time there's no selection in b4a for the cell's edittext. eg: the background color does not change, nor does the activity title show the cell's content. (This is neccessary to know which of the rows cell is editted.

The change in color and showing the cell's content only happens when you tap the same cell a second time.

Is there an solution for this? (because twice tapping for an selection is not the way to go ofcourse)

Update: Tried using the editText.l.InputType = edittext.INPUT_TYPE_NONE and then in the edittext_Click event as final line ime.showkeyboard.
This works, however, only when you press the cell twice. So the event is still triggered but suppressed, hence the need for pressing the cell twice.
Still no closer to a sollution..

Anybody?
 
Last edited:

Andrew4Good

Member
Licensed User
Longtime User
Indeed that did the trick.
Just changed the declaration of the label by an edittext and the INPUT_TYPE_NONE does not have to be used now.
The row changes color and the keyboard pops up.
However

Text from the IME library with Example:

Handling the screen size changed event

When the keyboard opens the available screen size becomes much shorter. By default if the EditText is located near the bottom of the screen, Android will "push" the whole activity and make the EditText visible. This mode is named "adjustPan" mode.

So I expected the edittext line to be 'pushed' above the keyboard, this does not happen, do I need to set something else for this?

Solution Code:
B4X:
Sub Cell_FocusChanged(HasFocus As Boolean)
    Dim rc As RowCol
    'Dim l As Label
    Dim l As EditText
 
    l = Sender
    rc = l.Tag
    SelectRow(rc)
    Activity.Title = "Cell: (" & rc.Row & ", " & rc.Col & ")  " & GetCell(rc.Row, rc.Col)
End Sub

For other users :)

Thanks Erel...
 
Upvote 0
Top