开发者

Android how to show another view on top of the existing ListView after checkbox is checked

Currently I have a list view within it ea开发者_运维知识库ch row has a checkbox attached. I would like that once any checkbox is checked, at the bottom of the screen a view displays, and once none of the checkboxes are checked, the view automatically disappeared. Possible to do this?

Any help or direction is appreciated. Thank you.


Yeah, you can do it.

Sounds like what you're looking for is a floating view at the bottom...

Try this example:

<?xml version="1.0" encoding="UTF-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

  <LinearLayout android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent">

    <ListView android:id="@android:id/list"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"/>
    <TextView android:id="@android:id/empty"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:text="@string/no_notes"/>

  </LinearLayout>

  <Button android:id="@+id/floating_button"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Floating Button"
              android:padding="5dip"
              android:layout_margin="5dip"
              android:layout_gravity="right|bottom" />
</FrameLayout>

In this example I used a button at the bottom, but you an use any view.

And to hide it you can use android:visibility or setVisibility(int visibility)

Hope that helped...


You will need to use a counter and couple it with addFooterView & removeFooterView.

When ever a checkbox is checked you need to update the counter in the onclicklistener for the checkbox and depending on the value of the counter add or remove the footer view.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜