Note that there are some explanatory texts on larger screens.

plurals
  1. POBuilding ActionMode with custom layout in ActionBarSherlock
    primarykey
    data
    text
    <p>I just starting using ActionBarSherlock for building some simple app, in my first screen I have simple list and I added new menu item for adding new item to the list:</p> <pre><code>MenuItem newItem = menu.add("New"); newItem.setIcon(R.drawable.ic_compose_inverse) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); </code></pre> <p>now when user choose to add a new item I want to start a new action mode for adding new item, this action mode should contain a simple layout with text box and a button, so I created this layout:</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"&gt; &lt;EditText android:id="@+id/text" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:inputType="text" &gt; &lt;/EditText&gt; &lt;Button android:id="@+id/addBtn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/add" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>so now I just need to set this layout to the bar in the new action mode:</p> <pre><code>newItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { actionMode = startActionMode(new MyAction(ListEditor.this)); return true; } }); </code></pre> <p>and in my action:</p> <pre><code>private final class MyAction implements ActionMode.Callback { ... @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { View customNav = LayoutInflater.from(context).inflate(R.layout.add_item, null); getSupportActionBar().setCustomView(customNav); getSupportActionBar().setDisplayShowCustomEnabled(true); return true; } } </code></pre> <p><strong>So basically I need something between ActionModes and CustomNavigation from the sherlock example, but the problem is that it set the layout to the main bar and not for the new bar that open in for action.</strong></p> <p>any suggestions?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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