Code example for ImageButton

Methods: setOnClickListenersetOnKeyListenersetOnLongClickListener

0
		mSearchHintTV.setText(searchHint);
	} 
	 
	public void setSystemSearchInvoker(final Activity activity) {
		 
		mSearchBox.setOnClickListener(new View.OnClickListener() {
			@Override 
			public void onClick(View v) {
				if(mSearchBox.isFocused()) {
					activity.onSearchRequested();
				} else { 
					mSearchBox.requestFocus();
				} 
			} 
		}); 
		 
		mSearchBox.setOnKeyListener(new View.OnKeyListener() {
			@Override 
			public boolean onKey(View v, int keyCode, KeyEvent event) {
				if(event.getUnicodeChar() != 0) {
					String initialSearch = new String(new int[] { event.getUnicodeChar() }, 0, 1);
					activity.startSearch(initialSearch, false, null, false);
					return true; 
				} 
				return false; 
			} 
		}); 
		 
		mSearchBox.setOnLongClickListener(new View.OnLongClickListener() {
			@Override 
			public boolean onLongClick(View v) {
				activity.onSearchRequested();
				return true; 
			} 
Stop searching for code, let great code find you!  Add Codota to your java IDE