Code example for ImageButton

Methods: setVisibility

     * 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,
        boolean voiceSearchVisible = ri != null;
        // finally, set visible state of voice search button, as appropriate 
        mVoiceButton.setVisibility(voiceSearchVisible ? View.VISIBLE : View.GONE);