0

This app tracks my workout routine and I wanted to share it with a few friends, so I need to make a button to add additional exercises. Currently I have an actionbar with the + button as per below, that expands to an editText field when pressed.

Image that I'm not allowed to post due to low rep...

Problem #1: The editText field seems to be set to wrap_Content, I would rather it fill remaining space but I have no idea how. It's been implemented like this;

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/menu_create"
        android:title="@string/menu_create"
        android:showAsAction="ifRoom|collapseActionView"
        android:actionViewClass="android.widget.EditText" />
</menu>

Problem #2: I need a button to appear as well that can be pressed once the name of the exercise has been typed in. So far I've had no luck figuring out how to do this. I'm just using the Android Dev Guide, I haven't been able to google anything that comes close to what I'm after...

Am I on the right track? If so, any tips/hints on how to add the button and fix up the editText field? If not, any suggestions for other ways to implement? (obviously a whole new activity is a bit of overkill...)

Sam
  • 86,580
  • 20
  • 181
  • 179
Trent
  • 1,595
  • 15
  • 37
  • 1
    You wrote: "I would rather it fill remaining space". You can use a custom ActionBar layout. See this as an example: http://stackoverflow.com/questions/13759148/center-searchview-in-action-bar/13837326#13837326 – Gunnar Karlsson Dec 16 '12 at 07:40

1 Answers1

0

Thanks for the tip @Gunnar Karlsson , a custom layout did the job for me. To be specific;

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <EditText
        android:id="@+id/exerciseInput"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:layout_weight="1" >
        <requestFocus />
    </EditText>

    <Button
        android:id="@+id/addExerciseButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/exerciseadd" />
</LinearLayout>
Trent
  • 1,595
  • 15
  • 37