Android Question Set focus in ACSearchView from button

Discussion in 'Android Questions' started by kris A, Jun 13, 2019.

  1. kris A

    kris A Member Licensed User

    Hi all,
    i want to set focus in ACSearchView from button click,
    is there any idea?

    Thanks.
     
  2. Brandsum

    Brandsum Well-Known Member Licensed User

    Try this (Not tested)
    Code:
    Dim r As Reflector
    r.Target = SearchBar
    r.Target = r.GetField(
    "mSearchView")
    Dim t As EditText = r.RunMethod4("findViewById"Array As Object(r.GetStaticField("android.support.v7.appcompat" & ".R$" & "id""search_src_text")), Array As String("java.lang.int"))
    t.RequestFocus
     
  3. kris A

    kris A Member Licensed User

    Hi brandsum,
    thanks for the help,
    I've tried your code but nothing happen
    Here my code,
    Code:
    Dim sv As ACSearchView
    Dim si As ACMenuItem
    Dim btnSearch As Button

    Sub Activity_CreateMenu(Menu As ACMenu)
        sv.Initialize2(
    "Search", sv.THEME_DARK)
        sv.IconifiedByDefault = 
    True
        
    Menu.Clear
        
    Dim xml As XmlLayoutBuilder
        si = 
    Menu.Add2(11"productSearch", xml.GetDrawable("ic_search_white_24dp"))
        si.SearchView = sv
    End Sub

    Sub btnSearch_Click
    End Sub
    i wanna give sv a focus (without si clicked), when user click btnSearch
    thanks before.
     
    Last edited: Jun 13, 2019
  4. kris A

    kris A Member Licensed User

    case close, ty brandsum for your time
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice