Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>FYI,</p> <p>This worked for me, gives me the EditText across the whole width of the ActionBar (which I couldn't seem to do without a RelativeLayout, even if using MenuItem.SHOW_AS_ACTION_ALWAYS) and call its TextWatcher methods:</p> <pre><code>EditText search; public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) { LayoutInflater inflater=(LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); RelativeLayout rl =(RelativeLayout)inflater.inflate(R.layout.search_text, null); search=(EditText)rl.getChildAt(0); search.addTextChangedListener(filterTextWatcher); menu.add(0, 1, 1, R.string.inlineSearch).setIcon(R.drawable.action_search).setActionView(rl).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); return super.onCreateOptionsMenu(menu); } private TextWatcher filterTextWatcher = new TextWatcher() { public void afterTextChanged(Editable s) { Log.e("TextWatcher","after"); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { Log.e("TextWatcher","before"); } public void onTextChanged(CharSequence s, int start, int before, int count) { Log.e("TextWatcher","onText"); } }; </code></pre> <p>&amp; my layout/search_text:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="fill_horizontal" &gt; &lt;EditText android:id="@+id/search_text" style="@style/EditTextHoloDark" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="4dip" android:imeActionId="1337" android:imeOptions="actionDone" android:inputType="textCapCharacters|textNoSuggestions" android:singleLine="true" android:hint="Search" android:textStyle="bold" android:drawableLeft="@drawable/action_search" /&gt; &lt;/RelativeLayout&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload