简体   繁体   English

如何在 android 中动态地将按钮放在 ExpandableListview 的末尾

[英]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.在我的应用程序中,我有一个扩展 ExpandableListActivity 的活动,我想在 ExpandableListview 的末尾放置一个按钮,这样如果我扩展它应该在 listview 的末尾。

The problem is after exapanding all the items in Expandablelistview it takes the full screen and the button does not appear.问题是在展开 Expandablelistview 中的所有项目后,它会全屏显示并且按钮不会出现。 How can I scroll button with ExpandableListview?如何使用 ExpandableListview 滚动按钮? I also tried to give Scrollview but its not working.我也试图给 Scrollview 但它不起作用。 Give me a way what should I write in xml file for proper o/p.给我一个方法,我应该在 xml 文件中写什么以获得正确的 o/p。 Thank you谢谢

Create a footerview layout consisting of Button that you want to set as footer and then try创建一个包含要设置为页脚的Button的页脚footerview layout ,然后尝试

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

Footer_layout xml file Footer_layout xml 文件

<?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> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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