Android Question Problem in AC library

Discussion in 'Android Questions' started by omidaghakhani1368, Mar 10, 2015.

  1. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    Hi again and i'm sorry for ask many question.
    I'm working with appcompat library
    I have 2 problem please help me to solve this problems
    1- How to change ACActiomMode Background color ? ( for me always black)
    2- How to work with ACSearchview (im initializing but cant show?)
     
    mjt-soft likes this.
  2. corwin42

    corwin42 Expert Licensed User

    It's better to ask each question in its own thread if they are not really related.

    1: You have to change the theme xml file. See this or this answer on StackOverflow.

    2: This is a bit like an undocumented feature. I never found the time to write a tutorial about it.

    - Initialize the SearchView with an EventName
    - Set it Iconified state by default sv.IconifiedByDefault = True
    - You have to use the advanced menu. I usually set it up with some java code. si is of type ACMenuItem,
    UIUtils.GetBitmapDrawable just loads a drawable. Just create a menu item and assign the searchview to it:
    :
    Code:
    #If Java

        public boolean _onCreateOptionsMenu(android.view.Menu menu) {
        if (processBA.subExists("activity_createmenu")) {
            processBA.raiseEvent2(null, true, "activity_createmenu", false, new de.amberhome.objects.appcompat.ACMenuWrapper(menu));
            return true;
        }
        else
            return false;
    }
    #End If

    Sub Activity_CreateMenu(Menu As ACMenu)
        
    Menu.Clear
        si = 
    Menu.Add2(11"Add location", UIUtils.GetBitmapDrawable("ic_action_search"))
        si.SearchView = sv
    End Sub
    - If the user presses the search menu item the ActionBar/Toolbar expands to an EditText view where he can enter his search text.
    - If the user presses enter/submits the search the Search_QuerySubmitted (Query As String) event is called where you can handle the search. In this event sub you should Iconify the Searchview again:
    Code:
    Sub Search_QuerySubmitted (Query As String)

        sv.Iconfied = 
    True
        si.ItemCollapsed = 
    True
       
       
    Do your search here.
    End Sub
     
  3. Ramezanpour2

    Ramezanpour2 Member Licensed User





    plesae add a sample source for this here thanks dear
     
  4. corwin42

    corwin42 Expert Licensed User

    You can find an example for the searchview at the first post of the AppCompat library thread.
     
  5. JohnCody

    JohnCody Well-Known Member Licensed User

    This might be a stupid question, but using this code:

    Code:
    Sub Activity_CreateMenu(Menu As ACMenu)
        sv.Initialize2(
    "Search", sv.THEME_DARK)
        sv.IconifiedByDefault = 
    True

        
    'Clear the menu
        Menu.Clear
           
        
    'Add a menu item and assign the SearchView to it
        si = Menu.Add2(11"Search"Null)
        si.SearchView = sv
       
        
    Menu.Add(2,0,"Test 1",Null)
        
    Menu.Add(3,0,"Test 2",Null)
    End Sub
    What would be the event sub_name to trap the selecting of "Test 1" or "Test 2" event?

    I ask because it seems you are making the menu in Java using this code:

    Code:
    'Inline Java code to initialize the Menu
    #If Java
        public boolean _onCreateOptionsMenu(android.view.Menu menu) {
            if (processBA.subExists("activity_createmenu")) {
                processBA.raiseEvent2(null, true, "activity_createmenu", false, new de.amberhome.objects.appcompat.ACMenuWrapper(menu));
                return true;
            }
            else
                return false;
        }
    #End If
    But I can't easily see what the menu "name" is to know what the first part of the event name should be.

    Any help would be greatly appreciated
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this question.
     
  7. JohnCody

    JohnCody Well-Known Member Licensed User

    I figured it out - I had to do a:
    Code:
    ActionBar.InitMenuListener
    Then the event sub name was:

    Code:
    Sub ActionBar_MenuItemClick (Item As ACMenuItem)
        
    Log("ActionBar_MenuItemClick event fired, id:" & Item.Id)
    End Sub
     
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