Bottom button bar overlaps the last element of Listview!

萝らか妹 提交于 2019-12-06 13:33:39

Didn't test this, but i am pretty sure it is the FrameLayout that is causing this :). Because FrameLayout does not care about the "weight" you gave it. FrameLayout just places the views you insert in front of each other. And the second one you gave, you said android:layout_gravity="bottom" which makes it align at the bottom. but just infront of the listview. Remove FrameLayout and it should work i think.

Try it like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:background="@android:color/transparent">

    <LinearLayout android:id="@+id/list_area"
        android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1">
        <ListView android:id="@+id/mylist" android:layout_width="fill_parent"
            android:layout_height="wrap_content" android:background="@android:color/transparent"
            android:drawSelectorOnTop="false" android:layout_weight="1" />

        <TextView android:id="@+id/empty_list_message"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:textColor="#FFFFFF" android:layout_gravity="center_vertical|center_horizontal"
            android:text="@string/msg_for_emptyschd" android:layout_margin="14dip"
            android:layout_weight="1" />
    </LinearLayout>

    <RelativeLayout android:id="@+id/bottom_action_bar"
        android:orientation="horizontal" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:background="@drawable/schedule_bottom_actionbar_border"
        android:layout_marginBottom="2dip"
        android:visibility="gone">
        <Button android:id="@+id/delete_selecteditems_button"
            android:text="Deleted Selected" android:layout_width="140dip"
            android:layout_height="40dip" android:layout_alignParentLeft="true"
            android:layout_marginLeft="3dip" android:layout_marginTop="3dip" />
        <Button android:id="@+id/cancel_button" android:text="Cancel"
            android:layout_width="140dip" android:layout_height="40dip"
            android:layout_alignParentRight="true" android:layout_marginRight="3dip"
            android:layout_marginTop="3dip" />
    </RelativeLayout>

</LinearLayout>

Seems like I have solved the problem of strange checkbox behavior. First, the problem was happening because as soon as the listview gets resized, it redraws itself, therefore getView() gets called again for all the visible list items. Since I am using a ViewHolder, and the view is getting reused, it seems like it causes the same checkbox to get reused again for some other list item. So therefore, when I was clicking one checkbox, some other checkbox was getting clicked instead. Since, this call to refresh the listview was only happening when the list was being resized, and list was getting resized only on marking a checkbox in list when no other checkbox was marked, this problem does not appear again after the first checkbox has been marked.

I solved the problem by creating a custom collection class to store the checked items, and before putting the item in this collection, I clone the clicked checkbox's tag and clicklistener over into a new checkbox and store that new checkbox now into the collection. This solved the strange behavior of checkboxes. This may not be the best solution to the problem, so if you know anything better than this, please share.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!