0

I am trying to add a bottom line ot the list view contained inside my container fragmentclass, However I tried adding views and dividers and it doesnt seem to quite do the trick. The container list contsists of 2 different rows which are alternating. I just need to add a generic line below this listview for it to work but so far have no luck, any suggesttions or clues? Thanks! Justin

        <RelativeLayout
            android:id="@+id/top_bar_container"
            android:layout_width="match_parent"
            android:layout_height="48.5dp"
            android:background="@color/background_action_bar"
            android:orientation="horizontal" >

            <ImageButton
                android:id="@+id/menu_button"
                android:layout_width="30dp"
                android:layout_height="48.5dp"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                android:background="@android:color/transparent"
                android:paddingRight="24dp"
                android:src="@drawable/overflow_btn" />

            <com.justin.abc.utils.FontView
                android:id="@+id/most_recent_text"
                android:layout_width="wrap_content"
                android:layout_height="48.5dp"
                android:layout_marginLeft="11dp"
                android:layout_marginRight="2dp"
                android:textColor="@color/white"
                foo:customFont="Cabin-Bold.ttf"
                android:layout_alignParentLeft="true"
                android:textSize="18sp"
                android:gravity="center_vertical"
                android:text="@string/most_recent"/>

        </RelativeLayout>

        <FrameLayout
            android:id="@+id/fragment_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/top_bar_container" >

            <ListView
                android:id="@+id/list"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

            <include layout="@layout/loading_no_results" />
        </FrameLayout>

    </RelativeLayout>

crash upon edit:

07-11 12:58:37.928: E/AndroidRuntime(3963):     at com..fragments.BriefcaseFragment.onCreateView(BriefcaseFragment.java:118)
07-11 12:58:37.928: E/AndroidRuntime(3963):     at android.support.v4.app.Fragment.performCreateView(Fragment.java:1460)
07-11 12:58:37.928: E/AndroidRuntime(3963):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:911)
07-11 12:58:37.928: E/AndroidRuntime(3963):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
07-11 12:58:37.928: E/AndroidRuntime(3963):     at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
07-11 12:58:37.928: E/AndroidRuntime(3963):     at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
07-11 12:58:37.928: E/AndroidRuntime(3963):     at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:429)
07-11 12:58:37.928: E/AndroidRuntime(3963):     at android.os.Handler.handleCallback(Handler.java:615)
07-11 12:58:37.928: E/AndroidRuntime(3963):     at android.os.Handler.dispatchMessage(Handler.java:92)
07-11 12:58:37.928: E/AndroidRuntime(3963):     at android.os.Looper.loop(Looper.java:213)
07-11 12:58:37.928: E/AndroidRuntime(3963):     at android.app.ActivityThread.main(ActivityThread.java:4787)
07-11 12:58:37.928: E/AndroidRuntime(3963):     at java.lang.reflect.Method.invokeNative(Native Method)
07-11 12:58:37.928: E/AndroidRuntime(3963):     at java.lang.reflect.Method.invoke(Method.java:511)
07-11 12:58:37.928: E/AndroidRuntime(3963):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
07-11 12:58:37.928: E/AndroidRuntime(3963):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
07-11 12:58:37.928: E/AndroidRuntime(3963):     at dalvik.system.NativeStart.main(Native Method)

1 Answers1

0

Would it not be easier to code it as follows:

<RelativeLayout>
    <RelativeLayout
        android:id="@+id/top_bar_container"
        android:layout_width="match_parent"
        android:layout_height="48.5 dp"
        android:layout_alignParentTop="true"
        android:background="@color/background_action_bar"
        android:orientation="horizontal" >
     <!-- Stuff for the top bar -->
    </RelativeLayout>

    <FrameLayout
        android:id="@+id/fragment_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/top_bar_container" >
        <!-- Stuff for the Frame -->
    </FrameLayout>

    <RelativeLayout
        android:id="@+id/bottom_bar_container"
        android:layout_below="@id/fragment_container"
        android:layout_width="match_parent"
        android:layout_height="48.5 dp"
        android:background="@color/background_action_bar"
        android:orientation="horizontal" >
     <!-- Stuff for the bottom bar -->
    </RelativeLayout>


</RelativeLayout>
Neil Townsend
  • 6,024
  • 5
  • 35
  • 52
  • The logic works great but it shows a wide empty space below the last item in the list ( which is composed of 4 items). is there anyway I can adjust the list height/relative height so it is more custom based on the items in the list so the line can be right below the last item in the list –  Jul 11 '13 at 16:33
  • crash: 07-11 12:53:40.040: E/AndroidRuntime(3012): FATAL EXCEPTION: main 07-11 12:53:40.040: E/AndroidRuntime(3012): java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.ListView –  Jul 11 '13 at 16:54
  • crashes with the same issue, I made all the changes as per your code, wonder what is causing it to be cast to a listview –  Jul 11 '13 at 16:57
  • i have added the crash log in the question –  Jul 11 '13 at 17:06
  • as soon as i add layout_below in any of the relative layouts it crashes, otherwise when fragment calls it, it doesnt crash but shows a blanks screen –  Jul 11 '13 at 17:18
  • It should only be "+id" in the `android:id` lines, all the rest should be "id" ... – Neil Townsend Jul 11 '13 at 17:31
  • you are right! works great! thanks! On similar lines, i have another question, if you have a chance to look at it : http://stackoverflow.com/questions/17597434/how-do-i-add-a-vertical-separator-line-between-3-displayed-values/17597639?noredirect=1#17597639, thanks!! –  Jul 11 '13 at 17:45
  • quick question, can you take a look at this : http://stackoverflow.com/questions/17846770/how-to-switch-button-image-from-on-to-off-and-vice-versa-upon-click/17846877?noredirect=1#17846877 and see if you have any clue about the same? Thanks! –  Jul 25 '13 at 00:15
  • @JusticeBauer Seen your request, am busy today, will think about it and reply as soon as I am able to. – Neil Townsend Jul 25 '13 at 06:54