简体   繁体   中英

how to put a button at the end of ExpandableListview dynamically in android

In my application i have an activity which extends ExpandableListActivity, there i want to put a button at the end of ExpandableListview, so that if i exapand it should be at the end of listview.

The problem is after exapanding all the items in Expandablelistview it takes the full screen and the button does not appear. How can I scroll button with ExpandableListview? I also tried to give Scrollview but its not working. Give me a way what should I write in xml file for proper o/p. Thank you

Create a footerview layout consisting of Button that you want to set as footer and then try

View footerView = ((LayoutInflater)ActivityContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.footer_layout, null, false);
ListView.addFooterView(footerView);

Footer_layout xml file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingTop="7dip"
    android:paddingBottom="7dip"
    android:orientation="horizontal"
    android:gravity="center">
    <LinearLayout 
        android:id="@+id/footer_layout" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="center"
        android:layout_gravity="center">

    <Button          
        android:id="@+id/footer_1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginRight="5dip">
    </Button> 

</LinearLayout>
 </LinearLayout> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM