Android Question Input box that close the app

anallie0

Active Member
Licensed User
Longtime User
I'm using the example of SearchView but I have two errors:

I added the input box in a panel, but when I press the delete key and the input box is empty, the app closes.

is indicated that IME is an uninitialized variable, but it is a library

The entire project is here: https://www.mediafire.com/?mrc1na8qbrtib3g
 

Attachments

  • screen1.png
    screen1.png
    7.7 KB · Views: 157
  • uscita.png
    uscita.png
    3.5 KB · Views: 178

anallie0

Active Member
Licensed User
Longtime User
Hi Erel, I copied exactly your example by adding the imputbox in a panel.
if the imputbox is empty and I press the delete key on the keyboard, the Activity closes.
There are no error messages if no one in the attached image.
 
Upvote 0

anallie0

Active Member
Licensed User
Longtime User
:)
Maybe I can not explain. I am attaching a picture.
when the textbox is empty and press the delete key (marked in red) the app closes.

in the Logs panel i see ** Activity (main) Pause, UserClosed=true **
 

Attachments

  • Screenshot_2014-01-05-17-15-26.png
    Screenshot_2014-01-05-17-15-26.png
    55.7 KB · Views: 144
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I have now tried the class SearchView.
I modified only 3 lines in the example, putting "sv" in a panel and everything is ok, clicking on "delete" when the edittext is empty too.
(sbaglio o sei italiano e mi fai fare una gran fatica? :). Come non detto, sei italiano e forse te lo avevo anche già chiesto)

B4X:
Sub Activity_Create(FirstTime As Boolean)
    pnl.Initialize("pnl")
    Activity.AddView(pnl, 0,0, 100%x, 100%y)
    sv.Initialize(Me, "sv")
    sv.AddToParent(pnl, 0, 0, 200dip, 300dip)


STOP! I'm not used IME!... I'll try again :)

Countermand: the IME is already in the example
 
Last edited:
Upvote 0

anallie0

Active Member
Licensed User
Longtime User
LucaMs il mio pannello l'ho messo da design ma si chiude anche l'app e non riesco a capire perchè.


B4X:
panelcerca.SetLayout(0%x, 0%y, 100%x, 100%y)
            sv.Initialize(Me, "sv")
            sv.AddToParent(panelcerca, 0%x, 0%y, 100%x, 70%y)
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
LucaMs il mio pannello l'ho messo da design ma si chiude anche l'app e non riesco a capire perchè.


B4X:
panelcerca.SetLayout(0%x, 0%y, 100%x, 100%y)
            sv.Initialize(Me, "sv")
            sv.AddToParent(panelcerca, 0%x, 0%y, 100%x, 70%y)


Uhm non mi sembra che quella classe sia fatta per metterla nel designer, ma l'ho guardata al volo. Riprovo (cioè, non così com'è!)
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Si, come dicevo, quella classe non è pronta per essere un Custom View. Quindi, l'avrai adattata, per metterla da Designer, giusto?
Il problema è sicuramente là... ora provo a tradurre, perché non siamo nel forum italiano ;)

To use that class in the designer you surely have adapted it for this purpose. The problem must be in that part of the code.
 
Upvote 0

anallie0

Active Member
Licensed User
Longtime User
se hai voglia e tempo ho allegato l'intero progetto se vuoi dagli un occhio....

ho messo solo il Panel con il design poi ho aggiunto la classe da codice

I only put the panel with the design then I added the code from class
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Il codice del tasto "Delete" è 67, non è KeyCodes.KEYCODE_BACK = 4,
per questo ti esce.
Ti basta aggiungere un "Or keycode = 67"

(se usi:
B4X:
Select Case KeyCode
  Case KeyCodes.KEYCODE_...
  Case KeyCodes.KEYCODE_...
End Select
è meglio)


Your code does not intercepted pressing the button that has a code different from the one you expected
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Così è meglio (anche se non è perfetta)

B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean

    Select Case KeyCode
  
        Case KeyCodes.KEYCODE_MENU, _
              KeyCodes.KEYCODE_VOLUME_DOWN, _
              KeyCodes.KEYCODE_VOLUME_UP, _
              KeyCodes.KEYCODE_DEL
            Return True

        Case KeyCodes.KEYCODE_BACK
            If panelcerca.Visible = True  Then  
                panelcerca.Visible=False
                Return True
            End If

            If panelconsulta.Visible = True  Then  
                panelconsulta.Visible=False
                'lista.SetSelection(0)
                Return True
            End If

            If panellista.Visible = True Then  
                panellista.Visible=False
                lista.SetSelection(0)
                Return True
            End If

        Case Else
      
            Activity.finish

    End Select

End Sub

P.S. dovrei andare a farmele, saranno come minimo 20 anni che non vado, hehehe
 
Upvote 0

anallie0

Active Member
Licensed User
Longtime User
grazie mille LucaMs, non pensavo che il tasto del della tastiera venisse intercettato dall'activity.

;)
 
Upvote 0
Top