Code example for ImageButton

Methods: setVisibility

0
 
    /** 
     * If appropriate & available, configure voice search 
     *  
     * Note:  Because the home screen search widget is always web search, we only check for 
     * getVoiceSearchLaunchWebSearch() modes.  We don't support the alternate form of app-specific 
     * voice search. 
     */ 
    private void configureVoiceSearchButton() { 
        // Enable the voice search button if there is an activity that can handle it 
        PackageManager pm = getContext().getPackageManager();
        ResolveInfo ri = pm.resolveActivity(mVoiceSearchIntent,
                PackageManager.MATCH_DEFAULT_ONLY);
        boolean voiceSearchVisible = ri != null;
 
        // finally, set visible state of voice search button, as appropriate 
        mVoiceButton.setVisibility(voiceSearchVisible ? View.VISIBLE : View.GONE);
    } 
     
    /** 
     * Sets the {@link Launcher} that this gadget will call on to display the search dialog.