Code example for ImageButton

Methods: isFocused, requestFocus

0
	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; 
				}